cat <<EOF > $dir_lstm/configs/network.xconfig
input dim=100 name=ivector
input dim=40 name=input
# please note that it is important to have input layer with the name=input
# as the layer immediately preceding the fixed-affine-layer to enable
# the use of short notation for the descriptor
fixed-affine-layer name=lda input=Append(-2,-1,0,1,2,ReplaceIndex(ivector, t, 0)) affine-transform-file=$dir_lstm/configs/lda.mat
# the first splicing is moved before the lda layer, so no splicing here
relu-batchnorm-layer name=tdnn1 dim=$hidden_dim
relu-batchnorm-layer name=tdnn2 input=Append(-1,0,1) dim=$hidden_dim
relu-batchnorm-layer name=tdnn3 input=Append(-1,0,1) dim=$hidden_dim
fast-lstmp-layer name=lstm1 cell-dim=$cell_dim recurrent-projection-dim=$projection_dim non-recurrent-projection-dim=$projection_dim delay=-3 dropout-proportion=0.0 $lstm_opts
relu-batchnorm-layer name=tdnn4 input=Append(-3,0,3) dim=$hidden_dim
relu-batchnorm-layer name=tdnn5 input=Append(-3,0,3) dim=$hidden_dim
fast-lstmp-layer name=lstm2 cell-dim=$cell_dim recurrent-projection-dim=$projection_dim non-recurrent-projection-dim=$projection_dim delay=-3 dropout-proportion=0.0 $lstm_opts
relu-batchnorm-layer name=tdnn6 input=Append(-3,0,3) dim=$hidden_dim
relu-batchnorm-layer name=tdnn7 input=Append(-3,0,3) dim=$hidden_dim
fast-lstmp-layer name=lstm3 cell-dim=$cell_dim recurrent-projection-dim=$projection_dim non-recurrent-projection-dim=$projection_dim delay=-3 dropout-proportion=0.0 $lstm_opts
relu-batchnorm-layer name=tdnn8 input=Append(-3,0,3) dim=$hidden_dim
relu-batchnorm-layer name=tdnn9 input=Append(-3,0,3) dim=$hidden_dim
fast-lstmp-layer name=lstm4 cell-dim=$cell_dim recurrent-projection-dim=$projection_dim non-recurrent-projection-dim=$projection_dim delay=-3 dropout-proportion=0.0 $lstm_opts
## adding the layers for chain branch
output-layer name=output input=lstm4 output-delay=$label_delay include-log-softmax=false dim=$num_targets max-change=1.5
# adding the layers for xent branch
# This block prints the configs for a separate output that will be
# trained with a cross-entropy objective in the 'chain' models... this
# has the effect of regularizing the hidden parts of the model. we use
# 0.5 / args.xent_regularize as the learning rate factor- the factor of
# 0.5 / args.xent_regularize is suitable as it means the xent
# final-layer learns at a rate independent of the regularization
# constant; and the 0.5 was tuned so as to make the relative progress
# similar in the xent and regular final layers.
output-layer name=output-xent input=lstm4 output-delay=$label_delay dim=$num_targets learning-rate-factor=$learning_rate_factor max-change=1.5
EOF