logo
Loading...

第5章第5節預測VIX手把手教學執行有錯誤 - Cupoy

MAX_CHAR_LENGTH = 120data_2d = cs.load_char('2d_cu...

第5章第5節預測VIX手把手教學執行有錯誤

2020/10/11 06:38 上午
張鴻承
觀看數:0
回答數:1
收藏數:0

MAX_CHAR_LENGTH = 120

data_2d = cs.load_char('2d_custom.csv', MAX_CHAR_LENGTH)

cs.save_model(split_date, data_2d, target_days=60, dim=MAX_CHAR_LENGTH, output_file='2d_60D_custom', epochs=50)

在執行 2d_custom時的報錯:


60 Days GRU Model Training WARNING:tensorflow:From C:\Users\Aleric\anaconda3\lib\site-packages\tensorflow\python\ops\init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor WARNING:tensorflow:From C:\Users\Aleric\anaconda3\lib\site-packages\tensorflow\python\keras\initializers.py:119: calling RandomUniform.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor Epoch 1/50 


--------------------------------------------------------------------------- ValueError                                Traceback (most recent call last) <ipython-input-4-338d769406cd> in <module>       1 MAX_CHAR_LENGTH = 120       2 data_2d = cs.load_char('2d_custom.csv', MAX_CHAR_LENGTH) ----> 3 cs.save_model(split_date, data_2d, target_days=60, dim=MAX_CHAR_LENGTH, output_file='2d_60D_custom', epochs=50) ~\AI股票交易引擎原始碼下載\CH4_CStock_v1_0_5\cstock.py in save_model(split_date, data_list, target_days, dim, output_file, batch_size, epochs, param)     993 else:     994             print(f'1 Day GRU Model Training') --> 995 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)     996 else:     997         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) ~\AI股票交易引擎原始碼下載\CH4_CStock_v1_0_5\cstock.py in gru_output(df, valid_date, test_date, model_file, dim, batch_size, close_60, epochs)     967         model = build_model()     968 #hist = model.fit_generator(generator=train_generator, validation_data=valid_generator, epochs=epochs, callbacks=[early_stopping, model_checkpoint]) --> 969 hist = model.fit(x=train_generator, validation_data=valid_generator, epochs=epochs, callbacks=[early_stopping, model_checkpoint])     970         bst_val_score = min(hist.history['val_loss'])     971         model.load_weights(f'{ROOT_PATH}{MODEL_PATH}{model_file}.h5') ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)     671           use_multiprocessing=use_multiprocessing,     672           shuffle=shuffle, --> 673           initial_epoch=initial_epoch)     674 if training_utils.is_eager_dataset_or_iterator(x):     675 # Make sure that y, sample_weights, validation_split are not passed. ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)    1431         shuffle=shuffle,    1432         initial_epoch=initial_epoch, -> 1433         steps_name='steps_per_epoch')    1434    1435   def evaluate_generator(self,  ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training_generator.py in model_iteration(model, data, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch, mode, batch_size, steps_name, **kwargs)     298 break     299 --> 300 aggregator.finalize()     301     results = aggregator.results     302     epoch_logs = cbks.make_logs(model, epoch_logs, results, mode) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training_utils.py in finalize(self)     109 def finalize(self):     110 if not self.results: --> 111 raise ValueError('Empty training data.')     112     self.results[0] /= self.num_samples_or_steps     113 ValueError: Empty training data. 


該怎麼解決?