问题描述
我正在尝试创建一个CNN来对数据进行分类.我的数据是X [N_data,N_features]我想创建一个能够对其进行分类的神经网络.我的问题是关于keras后端的Conv1D的输入形状.
I am trying to create a CNN to classify data. My Data is X[N_data, N_features]I want to create a neural net capable of classifying it. My problem is concerning the input shape of a Conv1D for the keras back end.
我想对一个过滤器重复一遍..假设有10个特征,然后对接下来的10个特征保持相同的权重.对于每个数据,我的卷积层将创建N_features/10个新神经元.我该怎么办?我应该在input_shape中输入什么?
I want to repeat a filter over.. let say 10 features and then keep the same weights for the next ten features.For each data my convolutional layer would create N_features/10 New neurones.How can i do so? What should I put in input_shape?
def cnn_model():
model = Sequential()
model.add(Conv1D(filters=1, kernel_size=10 ,strides=10,
input_shape=(1, 1,N_features),kernel_initializer= 'uniform',
activation= 'relu'))
model.flatten()
model.add(Dense(N_features/10, init= 'uniform' , activation= 'relu' ))
有什么建议吗?谢谢!
Any advice?thank you!
推荐答案
@Marcin的答案可能有用,但根据此处的文档可能会提出建议:
@Marcin's answer might work, but might suggestion given the documentation here:
将是:
model = Sequential()
model.add(Conv1D(filters=1, kernel_size=10 ,strides=10,
input_shape=(None, N_features),kernel_initializer= 'uniform',
activation= 'relu'))
请注意,由于输入数据(N_Data,N_features),我们将示例数设置为未指定(无).在这种情况下,strides
参数控制时间步的大小.
Note that since input data (N_Data, N_features), we set the number of examples as unspecified (None). The strides
argument controls the size of of the timesteps in this case.
这篇关于卷积神经网络Conv1d输入形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!