Skip to content

Commit

Permalink
remove natural gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
qindazhu committed Feb 5, 2020
1 parent 3c61cf5 commit bacf975
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions egs/wsj/s5/steps/libs/nnet3/xconfig/basic_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _generate_config(self):
# note: by default the LinearComponent uses natural gradient.
line = ('component name={0}.linear type=LinearComponent '
'orthonormal-constraint={1} param-stddev={2} '
'input-dim={3} output-dim={4} max-change=0.75 {5}'
'input-dim={3} output-dim={4} max-change=0.75 use-natural-gradient=false {5}'
''.format(self.name, self.config['orthonormal-constraint'],
self.config['orthonormal-constraint'] / math.sqrt(input_dim),
input_dim, bottleneck_dim, linear_options))
Expand All @@ -637,7 +637,7 @@ def _generate_config(self):


line = ('component name={0}.affine'
' type=NaturalGradientAffineComponent'
' type=AffineComponent'
' input-dim={1} output-dim={2} {3}'
''.format(self.name, cur_dim, output_dim, affine_options))
configs.append(line)
Expand Down Expand Up @@ -843,7 +843,7 @@ def _add_components(self, input_desc, input_dim, nonlinearities):
bottleneck_dim = self.config['bottleneck-dim']
# note: by default the LinearComponent uses natural gradient.
line = ('component name={0}.linear type=LinearComponent '
'input-dim={1} orthonormal-constraint=1.0 output-dim={2} {3}'
'input-dim={1} orthonormal-constraint=1.0 output-dim={2} {3} use-natural-gradient=false'
''.format(self.name, input_dim, bottleneck_dim, linear_options))
configs.append(line)
line = ('component-node name={0}.linear component={0}.linear input={1}'
Expand All @@ -853,7 +853,7 @@ def _add_components(self, input_desc, input_dim, nonlinearities):
cur_dim = bottleneck_dim


line = ('component name={0}.affine type=NaturalGradientAffineComponent'
line = ('component name={0}.affine type=AffineComponent'
' input-dim={1} output-dim={2} {3}'
''.format(self.name, cur_dim, output_dim, affine_options))
configs.append(line)
Expand Down
8 changes: 4 additions & 4 deletions egs/wsj/s5/steps/libs/nnet3/xconfig/composite_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _generate_config(self):
# The first linear layer, from input-dim (spliced x2) to bottleneck-dim
configs.append('component name={0}.linear type=TdnnComponent input-dim={1} '
'output-dim={2} l2-regularize={3} max-change={4} use-bias=false '
'time-offsets={5} orthonormal-constraint=-1.0'.format(
'time-offsets={5} orthonormal-constraint=-1.0 use-natural-gradient=false'.format(
name, input_dim, bottleneck_dim, l2_regularize,
max_change, time_offsets1))
configs.append('component-node name={0}.linear component={0}.linear '
Expand All @@ -176,7 +176,7 @@ def _generate_config(self):
# The affine layer, from bottleneck-dim (spliced x2) to output-dim
configs.append('component name={0}.affine type=TdnnComponent '
'input-dim={1} output-dim={2} l2-regularize={3} max-change={4} '
'time-offsets={5}'.format(
'time-offsets={5} use-natural-gradient=false'.format(
name, bottleneck_dim, output_dim, l2_regularize,
max_change, time_offsets2))
configs.append('component-node name={0}.affine component={0}.affine '
Expand Down Expand Up @@ -291,7 +291,7 @@ def _generate_config(self):
self_repair_scale = self.config['self-repair-scale']

# The affine layer, from input-dim to big-dim.
configs.append('component name={0}.affine type=NaturalGradientAffineComponent '
configs.append('component name={0}.affine type=AffineComponent '
'input-dim={1} output-dim={2} l2-regularize={3} max-change={4}'.format(
name, input_dim, big_dim, l2_regularize, max_change))
configs.append('component-node name={0}.affine component={0}.affine '
Expand All @@ -314,7 +314,7 @@ def _generate_config(self):
# ("floating" orthonormal constraint).
configs.append('component name={0}.linear type=LinearComponent '
'input-dim={1} output-dim={2} l2-regularize={3} max-change={4} '
'orthonormal-constraint=-1 '.format(
'orthonormal-constraint=-1 use-natural-gradient=false '.format(
name, big_dim, small_dim,
l2_regularize, max_change))
configs.append('component-node name={0}.linear component={0}.linear '
Expand Down
2 changes: 1 addition & 1 deletion egs/wsj/s5/steps/libs/nnet3/xconfig/trivial_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _generate_config(self):

configs = []
line = ('component name={0} type=LinearComponent input-dim={1} output-dim={2} '
'{3}'.format(self.name, input_dim, output_dim, opts))
'{3} use-natural-gradient=false'.format(self.name, input_dim, output_dim, opts))
configs.append(line)
line = ('component-node name={0} component={0} input={1}'.format(
self.name, input_desc))
Expand Down

0 comments on commit bacf975

Please sign in to comment.