ValueError: Failed to find data adapter that can handle input报错

报错内容:

ValueError: Failed to find data adapter that can handle input: <class ‘numpy.ndarray’>, (<class ‘list’> containing values of types {"<class ‘int’>"})

原因:

list类型是不能作为标签输入的,TensorFlow支持array输入

解决办法

把list转化为array:(这里举例要存入一个[0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]的数组)

  1. 新建一个空arraya = numpy.zeros(shape=(1, 15))
  2. 赋值a[0] = y
y = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
array_y = numpy.zeros(shape=(1, 15))
array_y [0] = y
model.fit(x, array_y , epochs=1)

结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_29391809/article/details/114648026