我試圖培養一批100塊的連體千層麪模型。 輸入是X1(100x3x100x100)和X2(相同大小)和Y(100x1),最後一層是密集層一個輸出維度,因爲我期望值爲0或1作爲目標值。但是,它會爲意外的維度引發錯誤。以下是代碼片段:千層麪的目標值形狀
input1 = lasagne.layers.InputLayer(shape=(None,3, 100, 100), input_var=None)
conv1_a = lasagne.layers.Conv2DLayer(input1,
num_filters=24,
filter_size=(7, 7),
nonlinearity=lasagne.nonlinearities.rectify)
pool1_a = lasagne.layers.MaxPool2DLayer(conv1_a, pool_size=(3, 3), stride=2)
第2層與上面相同。 輸出層:
dense_b = lasagne.layers.DenseLayer(dense_a,
num_units=128,
nonlinearity=lasagne.nonlinearities.rectify)
dense_c = lasagne.layers.DenseLayer(dense_b,
num_units=1,
nonlinearity=lasagne.nonlinearities.softmax)
net_output = lasagne.layers.get_output(dense_c)
true_output = T.ivector('true_output')
培訓代碼如下:
loss_value = train(X1_train,X2_train,Y_train.astype(np.int32))
print loss_value
ValueError: Input dimension mis-match. (input[0].shape[1] = 100, input[1].shape[1] = 1) Apply node that caused the error: Elemwise{Composite{((i0 * i1) + (i2 * log1p((-i3))))}}(InplaceDimShuffle{x,0}.0, LogSoftmax.0, Elemwise{sub,no_inplace}.0, SoftmaxWithBias.0) Toposort index: 113 Inputs types: [TensorType(int32, row), TensorType(float32, matrix), TensorType(float64, row), TensorType(float32, matrix)] Inputs shapes: [(1, 100), (100, 1), (1, 100), (100, 1)] Inputs strides: [(400, 4), (4, 4), (800, 8), (4, 4)] Inputs values: ['not shown', 'not shown', 'not shown', 'not shown'] Outputs clients: [[Sum{acc_dtype=float64}(Elemwise{Composite{((i0 * i1) + (i2 * log1p((-i3))))}}.0)]]
你還可以添加'dense_a'的定義嗎? –