jyoti
jyoti

Reputation: 65

Target value shape in Lasagne

I am trying to train a Siamese Lasagne model in batches of 100. The inputs are X1 (100x3x100x100) and X2 (same size) and Y(100x1) and my last layer is a Dense layer of one output dimension as I am expecting a value of 0 or 1 as a target value. However, it is throwing an error for unexpected dimension. Below are the code excerpts:

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)

Layer 2 is same as above. Output Layer:

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')

The training code is below:

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)]]

Upvotes: 1

Views: 127

Answers (1)

Andre Holzner
Andre Holzner

Reputation: 18675

Try using draw_net.py as follows:

import draw_net
dot = draw_net.get_pydot_graph(lasagne.layers.get_all_layers(your_last_layer), 
verbose = True)

dot.write("test.pdf", format="pdf")

to dump the Lasagne graph in pdf format (requires graphviz to be installed)

Upvotes: 0

Related Questions