尝试在Keras中拟合模型,如下所示进行初始化和编译,但得到None ValueErrors。建议的调试此类错误的方法有哪些?我是Keras的新手。
我可以更早地发现问题,即初始化或编译模型吗?
model = Model((64,64,3))
opt = keras.optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0)
binLoss = "binary_crossentropy"
model.compile(optimizer = opt, loss = binLoss, metrics = ["accuracy"])
ValueError Traceback (most recent call last)
<ipython-input-15-5b61099068d8> in <module>()
1 ### START CODE HERE ### (1 line)
----> 2 happyModel.fit(x = X_train, y = Y_train, epochs = 100, batch_size = 32)
3 ### END CODE HERE ###
/opt/conda/lib/python3.6/site-packages/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, **kwargs)
1574 else:
1575 ins = x + y + sample_weights
-> 1576 self._make_train_function()
1577 f = self.train_function
1578
...
/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
362 else:
363 if values is None:
--> 364 raise ValueError("None values not supported.")
365 # if dtype is provided, forces numpy array to be the type
366 # provided if possible.
ValueError: None values not supported.
答案 0 :(得分:1)
更新Keras,因为在2.1.3之前,“无”不是epsilon的有效参数
答案 1 :(得分:0)
这不是使用Keras API的有效模型构造。您应该看一下documentation,其中有30秒的指南显示了如何构建最小模型:
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(units=64, activation='relu', input_dim=100))
model.add(Dense(units=10, activation='softmax'))
# ...
如果您仍然对文档中所说的内容感到不满意,则可以从tutorial开始,在此过程中解释一些概念。
答案 2 :(得分:0)
用“ adam”代替opt可以解决问题,但是我不清楚为什么https://keras.io/optimizers/上的说明中的任何一个都应该起作用。