1
我有我想要輸入Keras的DNA數據,並且我有一個熱點編碼它使得每個DNA序列是4個通道(每個類型一個核苷酸)。我跟着一些教程,但我似乎有一個格式問題。也許有人可以幫助我?這是我第一次嘗試將自己的數據輸入Keras。我的數據是這樣的:使用4通道DNA數據輸入到Keras中的格式錯誤
print(x_train.shape) (1509, 4, 476) print(y_train.shape) (1509,)
我的模型(到目前爲止)看起來是這樣的:
###Setup Keras to create a convolutional recurrent NN
# set parameters:
batch_size = 32
filters = (32, 1, 2) #(number of filters, rows per convolution kernel, columns per convolution kernel)
kernel_size = 16
x_shape = (1509, 1, 476, 4) #(samples, height, width, depth)
epochs = 3
#declare model
model = Sequential()
#CNN Input layer
model.add(Conv2D(filters,
kernel_size,
padding='same',
activation='relu',
strides=(1,0),
input_shape=x_shape))
print(model.output_shape)
,但我得到了以下錯誤:
ValueError: Input 0 is incompatible with layer conv2d_0: expected ndim=4, found ndim=5
我不清楚爲什麼當我指定4維時,模型爲input_shape
參數找到5個維度。我錯過了什麼?