2
我想用遺傳算法訓練神經網絡。我使用tflearn庫創建我的網絡。當我預測一次網絡的結果時,一切都很好,但是當我在每次迭代中創建一個循環時,我會創建一個新的網絡模型,我會收到錯誤。在第一次迭代一切仍然有效,然而,在第二次迭代我有一個錯誤,說明:無法使用tflearn創建神經網絡的工作人口(Tensorflow)
不能喂形狀的值(145,如圖5所示,1)張量u'InputData/X:0' ,其中 具有形狀「(?,145,5,1)
我甚至試圖清除我的所有變量在循環結束後,重新創建類,並再次運行的功能,但在第二次迭代期間,我仍然有錯誤。
這是我的主:
for x in range(0, 5):
model = self.build_model()
result_ETH = self.calculate_model_performance(model)
這是我build_model
input_layer = input_data(shape = [None, self.input_length, self.input_types, 1])
fc1 = fully_connected(input_layer, self.neurons_layer_1, activation = 'relu', trainable = False, name = "full1")
fc2 = fully_connected(fc1, self.neurons_layer_2, activation = 'relu', trainable = False, name = "full2")
fc3 = fully_connected(fc2, self.neurons_layer_3, activation = 'relu', trainable = False, name = "full3")
network = fully_connected(fc3, 2, activation = 'softmax')
model = tflearn.DNN(network, clip_gradients=0., tensorboard_verbose=0)
return model
calculate_model_performance給予錯誤
predictset = self.create_predict_set(timepoint, ETH)
reshaped = predictset.reshape([-1,self.look_back+1,5,1])
prediction = model.predict(reshaped)
當我打印變量的重塑形狀的一部分,在第一次和第二次迭代中是相同的
你能修復代碼,以便我們可以運行呢?否則難以幫助。 –