Closed sorelyss closed 5 years ago
Yeah, that is because the file is meant to be used with the model trained on original svhn.
But, you should be able to use the script for the other models as well. You will need to change some parts of the code.
Size(width=50, height=50)
--input-width 185 --input-height 185
(that is the size of a typical grid like image)net, loc, transformed_output, size_params = SVHNMultiLineCTCNetwork.get_network(
data_shape,
output_size,
11,
4,
1,
blstm=True
)
And I think you should be good to go... at least I hope so...
Hi, thank you for the response. It raises this error. What is the set I have to put for l1_forward_init_h_state, l0_forward_init_h_state, etc?
infer_shape error. Arguments:
data: (1, 1, 185, 185)
l1_forward_init_h_state: (1, 1, 256)
l0_forward_init_h_state: (1, 1, 256)
softmax_label: (1, 3)
l0_forward_init_c_state_cell: (1, 1, 256)
l1_forward_init_c_state_cell: (1, 1, 256)
Traceback (most recent call last):
File "eval_svhn_model.py", line 110, in <module>
model = get_model(args, data_shape, output_size)
File "eval_svhn_model.py", line 51, in get_model
grad_req='null'
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/module/module.py", line 344, in bind
grad_req=grad_req, input_types=input_types)
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/module/executor_group.py", line 193, in __init__
self.bind_exec(data_shapes, label_shapes, shared_group)
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/module/executor_group.py", line 232, in bind_exec
self.execs.append(self._bind_ith_exec(i, data_shapes, label_shapes, shared_group))
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/module/executor_group.py", line 454, in _bind_ith_exec
arg_shapes, _, aux_shapes = self.symbol.infer_shape(**input_shapes)
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/symbol.py", line 535, in infer_shape
return self._infer_shape_impl(False, *args, **kwargs)
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/symbol.py", line 602, in _infer_shape_impl
ctypes.byref(complete)))
File "/home/sorelyss/Documents/test/incubator-mxnet/python/mxnet/base.py", line 75, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: Error in operator warpctc0: Shape inconsistent, Provided=(3,), inferred shape=(1,)
This error is one of the error I hate the most about MXNet... Short answer: hard to say, but it does not have to do anything with the lstm init state arrays.
My guess is that the softmax label input shape is wrong and it should be something like (1, 1)
You could have a look at this by using the SymbolDoc
Module of MXNet. This helps to debug shape errors.
It didn't work. I think i should try training the original data. However I think the train_svhn.py file has other parameters. I though putting something like:
image_size = Size(width=64, height=64)
source_shape = (args.batch_size, 1, image_size.height, image_size.width)
target_shape = Size(width=40, height=40)
# adjustable network parameters
num_timesteps = 11
labels_per_timestep = 3
num_rnn_layers = 2
label_width = num_timesteps // labels_per_timestep
use_blstm = False
net, loc, transformed_output, size_params = SVHNMultiLineCTCNetwork.get_network(
source_shape,
target_shape,
num_timesteps,
num_rnn_layers,
label_width,
blstm=use_blstm,
fix_loc=args.fix_loc
)
would work (I tried to replicate the parameters in the evaluation file), but this also didn't. It raises:
Traceback (most recent call last):
File "train_svhn2.py", line 105, in <module>
first_batch = next(iter(val_iter))
File "/home/sorelyss/Documents/test/stn-ocr/mxnet/data_io/lstm_iter.py", line 23, in __next__
return self.next()
File "/home/sorelyss/Documents/test/stn-ocr/mxnet/data_io/lstm_iter.py", line 80, in next
iter_batch = self.iter.next()
File "/home/sorelyss/Documents/test/stn-ocr/mxnet/data_io/file_iter.py", line 121, in next
raise StopIteration
StopIteration
Can I have the training file for the original data?
Well, this is definitely a problem, I'm sorry about that... Just to be clear: You want to train a model on the regular grid dataset, right?
You will need to set the parameters to the following:
image_size = Size(width=185, height=185)
source_shape = (args.batch_size, 1, image_size.height, image_size.width)
target_shape = Size(width=50, height=50)
# adjustable network parameters
num_timesteps = 4
labels_per_timestep = 4
num_rnn_layers = 1
label_width = num_timesteps * labels_per_timestep
use_blstm = False
This should be correct settings for training such a network.
Regarding your Error:
There is something going wrong in the data loading Code. You can have a look at the function _load_worker
here and do some debugging here. It could be an image loading exception or the calculated number of labels does not match the actual number of labels per image.
No, I want to train the one called "original_svhn" because those models work with the evaluation file. I think is the generated centered dataset, right?
I can train using the train_svhn.py file, but this has another model's parameters.
python train_svhn.py ../datasets/svhn/generated/centered/train2.csv ../datasets/svhn/generated/centered/valid2.csv --log-dir ../logs --save-model-prefix svhn_train_model -b 2 --lr 1e-5 --zoom 0.5 -ci 500 --char-map ../datasets/svhn/svhn_char_map.json
I want to know the parameters for the "original_svhn".
If you want to train on original SVHN data, you will:
Once you are done with this, you have to change the parameters to:
image_size = Size(width=64, height=64)
source_shape = (args.batch_size, 1, image_size.height, image_size.width)
target_shape = Size(width=40, height=40)
# adjustable network parameters
num_timesteps = 5
labels_per_timestep = 1
num_rnn_layers = 1
label_width = num_timesteps * labels_per_timestep
use_blstm = False
This should work... at least I hope so...
Thanks
Hi, I was trying to run your demos but I only make it to work for the original_svhn model, I also tried to train one by myself but at the end it raises the same size error.
When I do:
Works perfect.
However, when I try:
It raises the following error, I have tried to pass a different --input-width and --input-height but it seems that the problem is not there.