可以将可变长度(即input_dim=None
)应用于简单的神经网络吗?具体来说,是Keras顺序模型。尝试采用相同的概念时,我一直遇到错误。我已经看过似乎支持此功能的文档:
https://keras.io/getting-started/functional-api-guide/
但是当我执行以下操作时...
model = Sequential()
model.add(Dense(num_feat, input_dim = None, kernel_initializer = 'normal', activation='relu'))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(ouput.shape[1], kernel_initializer = 'normal', activation = 'linear'))
...我收到此错误:
ValueError: ('Only Theano variables and integers are allowed in a size-tuple.', (None, 63), None)
任何帮助,想法或澄清将不胜感激!
答案 0 :(得分:1)
不,您不能。 (而且您也不能使用功能性API)
权重矩阵的大小固定,此大小取决于输入的暗淡。
可能的变量尺寸为:
input_shape=(None,channels)
input_shape=(None,None,channels)
input_shape=(None,None,None,channels)
input_shape = (None, features)
batch_shape
或batch_input_shape
而不是input_dim
batch_shape=(None,input_dim)
或batch_input_shape=(None,input_dim)