From 689b78e4f418430dee80dc993331f9e3571f36eb Mon Sep 17 00:00:00 2001 From: pswietojanski Date: Sun, 15 Nov 2015 16:45:41 +0000 Subject: [PATCH] adding missing conv compatibility code in fc linear transform --- mlp/layers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mlp/layers.py b/mlp/layers.py index f3a17e1..5c0af09 100644 --- a/mlp/layers.py +++ b/mlp/layers.py @@ -265,6 +265,11 @@ class Linear(Layer): :param inputs: matrix of features (x) or the output of the previous layer h^{i-1} :return: h^i, matrix of transformed by layer features """ + + #input comes from 4D convolutional tensor, reshape to expected shape + if inputs.ndim == 4: + inputs = inputs.reshape(inputs.shape[0], -1) + a = numpy.dot(inputs, self.W) + self.b # here f() is an identity function, so just return a linear transformation return a @@ -334,6 +339,10 @@ class Linear(Layer): since W and b are only layer's parameters """ + #input comes from 4D convolutional tensor, reshape to expected shape + if inputs.ndim == 4: + inputs = inputs.reshape(inputs.shape[0], -1) + #you could basically use different scalers for biases #and weights, but it is not implemented here like this l2_W_penalty, l2_b_penalty = 0, 0