A_0xl
2021-07-02 15:44
采纳率: 50%
浏览 106

构建神经网络模型报错<class 'int'>,

model.compile(loss='binary_crossentropy', 
              optimizer='adam',
              metrics=['accuracy'])

train_history = model.fit(x_train,y_train,batch_size=100,
                          epochs=1,verbose=2,
                          validation_split=0.2)

然后就好多<class 'int'>,,之前也建立CNN模型,一切都正常,不知道这次是怎么回事

<ipython-input-38-a4c83fbcf656> in <module>
      1 train_history = model.fit(x_train,y_train,batch_size=100,
      2                           epochs=1,verbose=2,
----> 3                           validation_split=0.2)

~\anaconda3\envs\ten\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_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
   1039       (x, y, sample_weight), validation_data = (
   1040           data_adapter.train_validation_split(
-> 1041               (x, y, sample_weight), validation_split=validation_split))
   1042 
   1043     if validation_data:

~\anaconda3\envs\ten\lib\site-packages\tensorflow\python\keras\engine\data_adapter.py in train_validation_split(arrays, validation_split)
   1357     raise ValueError(
   1358         "`validation_split` is only supported for Tensors or NumPy "
-> 1359         "arrays, found following types in the input: {}".format(unsplitable))
   1360 
   1361   if all(t is None for t in flat_arrays):

ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following types in the input: [<class 'int'>,

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • 吃肉的小馒头 2021-07-02 15:58

    检查 x_train,y_train 数据类型是否tensors或numpy

    评论
    解决 1 无用
    打赏 举报

相关推荐 更多相似问题