Part2_model_training.ipynb 執行失敗
IndexError Traceback (most recent call last)
<ipython-input-4-6ce4e3a25691> in <module>
1 MAX_CHAR_LENGTH = 120
2 data_2d = cs.load_char('2d_char.csv', MAX_CHAR_LENGTH)
----> 3 cs.save_model(split_date, data_2d, target_days=60, dim=MAX_CHAR_LENGTH, output_file='2d_60D_model')
~\第四章股市 - 股票交易引擎主程式\CH4_CStock\cstock.py in save_model(split_date, data_list, target_days, dim, output_file, batch_size, epochs, param)
975 else:
976 print(f'1 Day GRU Model Training')
--> 977 gru_output(df, valid_date=valid_date, test_date=test_date, close_60=close_60, model_file=output_file, batch_size=batch_size, epochs=epochs)
978 else:
979 train_X, train_Y, train_Y60, valid_X, valid_Y, valid_Y60, test_X, test_Y, test_Y60 = data_split(df, valid_date, test_date, select_code)
~\第四章股市 - 股票交易引擎主程式\CH4_CStock\cstock.py in gru_output(df, valid_date, test_date, model_file, dim, batch_size, close_60, epochs)
953 bst_val_score = min(hist.history['val_loss'])
954 model.load_weights(f'{ROOT_PATH}{MODEL_PATH}{model_file}.h5')
--> 955 y_test = test_target(df, dim=dim, start_date=test_date, close_60=close_60)
956 yhat = model.predict_generator(test_generator, verbose=1)
957 yhat = np.squeeze(yhat)
~\第四章股市 - 股票交易引擎主程式\CH4_CStock\cstock.py in test_target(data, dim, start_date, end_date, close_60)
913 df = df[df['日期'] < end_date].reset_index(drop=True)
914 if len(df)>dim:
--> 915 cut_index = df.index[df['日期'] >= start_date].tolist()[0]
916 cut_index = max(cut_index-dim+1, 0)
917 df = df.iloc[cut_index:].reset_index(drop=True)
IndexError: list index out of range
回答列表
-
2020/07/29 下午 02:25陳明佑 (Ming You Chen)贊同數:0不贊同數:0留言數:0
你的問題在比較新的版本上已經修正
請先到本課程首頁的第一篇置頂公告中, 下載最新版本的程式