diff options
Diffstat (limited to 'model/hpc_lstm.py')
-rw-r--r-- | model/hpc_lstm.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/model/hpc_lstm.py b/model/hpc_lstm.py index 395646c..d3c33a2 100644 --- a/model/hpc_lstm.py +++ b/model/hpc_lstm.py @@ -10,7 +10,7 @@ from blocks.initialization import IsotropicGaussian, Constant from blocks.filter import VariableFilter from blocks.roles import WEIGHT -from blocks.graph import ComputationGraph, apply_noise, apply_dropout +from blocks.graph import ComputationGraph, apply_noise class Model(): @@ -103,10 +103,20 @@ class Model(): # Initialize all bricks for brick in bricks: - brick.weights_init = IsotropicGaussian(0.1) - brick.biases_init = Constant(0.) + brick.weights_init = config.weights_init + brick.biases_init = config.biases_init brick.initialize() + # apply noise + cg = ComputationGraph([sgd_cost, cost, error_rate]+costs) + if config.weight_noise > 0: + noise_vars = VariableFilter(roles=[WEIGHT])(cg) + cg = apply_noise(cg, noise_vars, config.weight_noise) + sgd_cost = cg.outputs[0] + cost = cg.outputs[1] + error_rate = cg.outputs[2] + costs = cg.outputs[3:] + # put stuff into self that is usefull for training or extensions self.sgd_cost = sgd_cost |