Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #131 from mangwang/master
Browse files Browse the repository at this point in the history
sknn unit test date type error
  • Loading branch information
alexjc committed Nov 20, 2015
2 parents 3a06089 + e46e9a6 commit a56243c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sknn/backend/lasagne/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ def _array_to_mlp(self, array, nn):
ws = tuple(layer.W.shape.eval())
assert ws == weights.shape, "Layer weights shape mismatch: %r != %r" %\
(ws, weights.shape)
layer.W.set_value(weights)
layer.W.set_value(weights.astype(theano.config.floatX))

bs = tuple(layer.b.shape.eval())
assert bs == biases.shape, "Layer biases shape mismatch: %r != %r" %\
(bs, biases.shape)
layer.b.set_value(biases)
layer.b.set_value(biases.astype(theano.config.floatX))
12 changes: 6 additions & 6 deletions sknn/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def test_SetLayerParamsList(self):
nn.set_parameters([(weights, biases)])

p = nn.get_parameters()
assert_true((p[0].weights == weights).all())
assert_true((p[0].biases == biases).all())
assert_true((p[0].weights.astype('float32') == weights.astype('float32')).all())
assert_true((p[0].biases.astype('float32') == biases.astype('float32')).all())

def test_LayerParamsSkipOneWithNone(self):
nn = MLPR(layers=[L("Sigmoid", units=32), L("Linear", name='abcd')])
Expand All @@ -73,8 +73,8 @@ def test_LayerParamsSkipOneWithNone(self):
nn.set_parameters([None, (weights, biases)])

p = nn.get_parameters()
assert_true((p[1].weights == weights).all())
assert_true((p[1].biases == biases).all())
assert_true((p[1].weights.astype('float32') == weights.astype('float32')).all())
assert_true((p[1].biases.astype('float32') == biases.astype('float32')).all())

def test_SetLayerParamsDict(self):
nn = MLPR(layers=[L("Sigmoid", units=32), L("Linear", name='abcd')])
Expand All @@ -86,5 +86,5 @@ def test_SetLayerParamsDict(self):
nn.set_parameters({'abcd': (weights, biases)})

p = nn.get_parameters()
assert_true((p[1].weights == weights).all())
assert_true((p[1].biases == biases).all())
assert_true((p[1].weights.astype('float32') == weights.astype('float32')).all())
assert_true((p[1].biases.astype('float32') == biases.astype('float32')).all())

0 comments on commit a56243c

Please sign in to comment.