-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1009 from dwf/linear_interface_refactor
Refactor common stuff from Linear and Convolutional
- Loading branch information
Showing
8 changed files
with
93 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import numpy | ||
import theano | ||
from theano import tensor | ||
from blocks.bricks import Linear | ||
from blocks.initialization import Constant, IsotropicGaussian | ||
|
||
|
||
def test_linearlike_subclass_initialize_works_overridden_w(): | ||
class NotQuiteLinear(Linear): | ||
@property | ||
def W(self): | ||
W = super(NotQuiteLinear, self).W | ||
return W / tensor.sqrt((W ** 2).sum(axis=0)) | ||
|
||
brick = NotQuiteLinear(5, 10, weights_init=IsotropicGaussian(0.02), | ||
biases_init=Constant(1)) | ||
brick.initialize() | ||
assert not numpy.isnan(brick.parameters[0].get_value()).any() | ||
numpy.testing.assert_allclose((brick.W ** 2).sum(axis=0).eval(), 1, | ||
rtol=1e-6) |