GruStepLayer parameter sharing issue
Currently the design is that if two GRU layers have the same para_prefix, then their parameters are shared.
GruStepLayer takes the first input's parameter name and creates a set of parameters:
self.create_input_parameter(0, size * size * 3, [size, size * 3])
However, in GatedRecurrentUnit the parameter name is assigned to the second input (memory). Thus even when two GatedRecurrentUnits have the same para_prefix, the parameters will not be shared.
There is probably the same issue in other layers that use GruStepLayer, where para_prefix is not specified for the first input of GruStepLayer.
@yu239 If you could provide some code example, it might help us understand the problem better.
@wangyang59
In the implementation of GatedRecurrentUnit:
GruStepLayer(
name=name,
size=size,
bias=Bias(parameter_name=para_prefix + "_gate.b"),
inputs=[
input_layer_name, Input(
out_memory, parameter_name=para_prefix + "_gate.w")
],
active_type=active_type,
active_gate_type=gate_active_type, )
The second entry (out_memory) of inputs has parameter name, but not the first one (input_layer_name). GruStepLayer creates the parameters as follows:
self.create_input_parameter(0, size * size * 3, [size, size * 3])
'0' means the first input. Since para_prefix is not used for the first input, the parameters could never be shared.
A possible hack would be to assign the parameter name to the first input instead:
inputs=[
Input(input_layer_name,
parameter_name=para_prefix + "_gate.w"),
out_memory
]
In this way, two GatedRecurrentUnits that have the same para_prefix would share the same set of parameters.