【发布时间】:2020-04-21 22:34:50
【问题描述】:
我有以下输入数组,我想将其提供给 CNN
import numpy as np
from keras.layers import Input, Dense, Conv2D
#dummy data for 1d array
width = 5
levels = 4
inputArray =np.random.randint(low=0, high=levels, size=20)
inputArray_ = inputArray.reshape(-1,width) #reshape to 2d array
网络的第一层是:
x = Conv2D(16, (3, 3), activation='relu', padding='same')(inputArray_)
我收到以下错误:
ValueError: Layer conv2d_13 was called with an input that isn't a symbolic tensor. Received type: <class 'numpy.ndarray'>. Full input: [array([[3, 1, 1, 1, 1],
[0, 1, 3, 1, 3],
[0, 0, 2, 0, 0],
[1, 3, 2, 2, 0],
[1, 1, 2, 1, 1],
[0, 3, 1, 3, 0],
[3, 1, 2, 3, 2],
[1, 2, 0, 2, 2],
[3, 2, 2, 1, 0],
[1, 2, 1, 3, 1],
[0, 3, 2, 3, 0],
[0, 3, 1, 0, 0],
[2, 2, 0, 0, 2],
[2, 2, 1, 0, 1],
[3, 3, 0, 3, 1],
[0, 0, 3, 1, 0],
[1, 3, 1, 2, 2],
[1, 0, 3, 2, 2],
[3, 1, 2, 1, 2],
[3, 0, 3, 3, 1]])]. All inputs to the layer should be tensors.
【问题讨论】:
标签: python keras keras-layer