您好,我在制作一个使用 openaigym 播放 Cartpole 的循环神经网络时遇到此值错误 -Traceback (most recent call last): File "C:/Users/Tejas/Desktop/ML Laboratory/Deep Learning/Neural Networks/4. Sentdex/Part - 3/Gym.py", line 147, in train_model model.fit(X, y, batch_size=64, epochs = 5) File "C:\Users\Tejas\Anaconda3\envs\tensorflow_gpuenv\lib\site-packages\keras\engine\training.py", line 952, in fit batch_size=batch_size) File "C:\Users\Tejas\Anaconda3\envs\tensorflow_gpuenv\lib\site-packages\keras\engine\training.py", line 789, in _standardize_user_data exception_prefix='target') File "C:\Users\Tejas\Anaconda3\envs\tensorflow_gpuenv\lib\site-packages\keras\engine\training_utils.py", line 102, in standardize_input_data str(len(data)) + ' arrays: ' + str(data)[:200] + '...')ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 19570 arrays: [array([[0], [1]]), array([[1], [0]]), array([[0], [1]]), array([[1], [0]]), array([[1], [0]]), array([[1], [0]]), array([[1], [0]]), array([[0], ...这是我制作的循环神经网络模型。我认为必须在定义中进行一些更改,必须在此处进行-def neural_network_model(input_size): model = Sequential() model.add(CuDNNLSTM(128, input_shape=(input_size, 1), return_sequences=True)) model.add(Dropout(0.8)) model.add(CuDNNLSTM(256, return_sequences=True)) model.add(Dropout(0.8)) model.add(CuDNNLSTM(512)) model.add(Dropout(0.8)) model.add(Dense(128, activation='relu')) model.add(Dropout(0.8)) model.add(Dense(2, activation='softmax')) return model我不明白为什么给我这个错误。我试过改变输入形状和许多其他东西,但没有一个能解决我的问题。如果你需要完整的代码,如果你认为这会有所帮助,你可以从这里获取 -完整代码
添加回答
举报
0/150
提交
取消