我在这里附加了我的代码。它完全没有任何错误地学习,但是当我想在lambda层之后显示层的输出时,它会产生这个错误。
InvalidArgumentError:您必须为占位符张量'input_78'提供一个值,其中dtype为float和shape [?,28,28,1] [[{{node input_78}} = Placeholderdtype = DT_FLOAT,shape = [?,28,28,1 ],_ device =“/ job:localhost / replica:0 / task:0 / device:GPU:0”]] [[{{node lambda_35 / add / _2359}} = _Recvclient_terminated = false,recv_device =“/ job:localhost / replica:0 / task:0 / device:CPU:0“,send_device =”/ job:localhost / replica:0 / task:0 / device:GPU:0“,send_device_incarnation = 1,tensor_name =”edge_50_lambda_35 / add“ ,tensor_type = DT_FLOAT,_device =“/ job:localhost / replica:0 / task:0 / device:CPU:0”]]
我之前实现了这段代码而没有添加w_expanded作为fit函数的输入,它显示输出没有错误,但是使用这段代码,它产生了上面提到的错误。我不明白为什么它显示这个错误?请帮我。我真的需要解决方案。








X = x_test[i:i+1]
# Visualize weights
W = model.layers[1].get_weights()[0][:,:,0,:]
w1=W.reshape(16,3,3)
W = np.squeeze(w1)
print("W shape : ", W.shape)
for i in range(0,16):
plt.subplot(4,4,i+1)
plt.imshow(w1[i,:,:], interpolation='nearest',cmap='gray')
plt.show()
W = model.layers[2].get_weights()[0][:,:,0,:]
w2=W.reshape(8,3,3)
W = np.squeeze(w2)
print("W shape : ", W.shape)
for i in range(0,8):
plt.subplot(4,4,i+1)
plt.imshow(w2[i,:,:], interpolation='nearest',cmap='gray')
plt.show()