Closed oftenliu closed 6 years ago
Whereas most activation functions (ReLU, sigmoid, tanh) have their phase change at zero, and random weight initializers tend to be symmetric about this point also, it's best to keep your raw input data nominally centered around zero.
so, like Batch Normalization?
and another question is that in last layer, the output should be the probability of each char, but you use Relu as activation function. why not softmax
Yes, similar to batch norm. The CTC loss layer utilizes raw scores as their input, taking the softmax internally.
ho, i use your project to train my plate data, the num of chars classes is 66,i change the num from 63 to 67 in "logits = model.rnn_layers( features, sequence_length, 66) " [train.py, line number = 178 ],and the failure message occurs like this:
Caused by op 'save/Assign_109', defined at:
File "D:/learn/ocr/cnn_lstm_ctc_ocr-master/ocr_cnn_lstm_ctc/src/train.py", line 209, in
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [67] rhs shape= [63] [[Node: save/Assign_109 = Assign[T=DT_FLOAT, _class=["loc:@rnn/logits/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](rnn/logits/bias, save/RestoreV2:109)]]
Traceback (most recent call last): File "D:\software\cuda\Anaconda2-4.3.1\envs\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1322, in _do_call return fn(*args) File "D:\software\cuda\Anaconda2-4.3.1\envs\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1307, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "D:\software\cuda\Anaconda2-4.3.1\envs\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1409, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [67] rhs shape= [63] [[Node: save/Assign_109 = Assign[T=DT_FLOAT, _class=["loc:@rnn/logits/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](rnn/logits/bias, save/RestoreV2:109)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/learn/ocr/cnn_lstm_ctc_ocr-master/ocr_cnn_lstm_ctc/src/train.py", line 209, in
Caused by op 'save/Assign_109', defined at:
File "D:/learn/ocr/cnn_lstm_ctc_ocr-master/ocr_cnn_lstm_ctc/src/train.py", line 209, in
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [67] rhs shape= [63] [[Node: save/Assign_109 = Assign[T=DT_FLOAT, _class=["loc:@rnn/logits/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](rnn/logits/bias, save/RestoreV2:109)]]
this means i load 67 elements into variable with 63 elements , so my channges is invalid.
can you guide me to change this. thank you very much
@oftenliu I don't have any clear ideas why this would happen. One long-shot possibility is that you'd trained and saved a 63-dim model checkpoint (it's automatic) before making the change. train.py
loads an existing checkpointed model (again, automatically), so that could be the case of the discrepancy.
To verify you're starting from scratch, either make sure ROOT/data/model
is deleted or you use a different path for the --output
flag.
Perfectly, As you said,i saved a 63-dim model checkpoint before making the change. You are really something!!! thank you
excuse me,in function _preprocess_image(image) (Mjsynth.py), why rescale the pixels value to float([-0.5,0.5]) not float([0,1]). can u tell me why? tks