Problems when saving network with GRU
gonza-bp opened this issue · comments
Dear sir/madam,
I am using the following packages with their versions:
nnabla 1.13.0
nnabla-ext-cuda 1.0.18
nnabla-ext-cuda90 1.13.0
I am trying to save a neural network which contains a GRU layer but it is crashing.
As an example I have used the following code:
import nnabla as nn
import nnabla.functions as F
import nnabla.parametric_functions as PF
import nnabla.solvers as S
from nnabla.utils.save import save as save_nn
seq_len = 10
batch_size = 64
input_size = 30
hidden_size = 20
num_layers = 2
num_directions = 1
nn.clear_parameters()
x = nn.Variable((seq_len, batch_size, input_size))
h = nn.Variable((num_layers, num_directions, batch_size, hidden_size))
y, hn = PF.gru(x, h)
contents = {
'networks': [
{'name': 'gru',
'batch_size': batch_size,
'outputs': {'y': y},
'names': {'x': x}}],
'executors': [
{'name': 'runtime',
'network': 'gru',
'data': ['x'],
'output': ['y']}]}
save_nn("gru.nnp",contents)
However, I am receiving the following error: ValueError: Variable "GRU_Input" has different batch size 2 (expected 10)
Maybe, I am doing something wrong in my code.
Thank you very much,
Gonzalo
You may overcome this problem by calling save_nn() with an option:
...
save_nn("gru.nnp", contents, variable_batch_size=False)
I hope his answer helps you.
If this answer is insufficient for your requirement, please submit new github issue.