githubharald / SimpleHTR

Handwritten Text Recognition (HTR) system implemented with TensorFlow.
https://towardsdatascience.com/2326a3487cd5
MIT License
1.99k stars 893 forks source link

i just try to train a model from the scratch but it it will show the error. can you help mee? #149

Closed harinath23 closed 2 years ago

harinath23 commented 2 years ago

CNN output shape: (None, 32, 1, 256) C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py:79: UserWarning: tf.nn.rnn_cell.LSTMCell is deprecated and will be removed in a future version. This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0. cells = [tf.compat.v1.nn.rnn_cell.LSTMCell(num_units=numHidden, state_istuple=True) for in range(2)] # 2 layers WARNING:tensorflow:tf.nn.rnn_cell.MultiRNNCell is deprecated. This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0. WARNING:tensorflow:From C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py:86: bidirectional_dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version. Instructions for updating: Please use keras.layers.Bidirectional(keras.layers.RNN(cell)), which is equivalent to this API WARNING:tensorflow:From C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\rnn.py:437: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version. Instructions for updating: Please use keras.layers.RNN(cell), which is equivalent to this API WARNING:tensorflow:From C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\keras\layers\rnn\legacy_cells.py:958: calling Zeros.init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor 2022-09-16 15:28:17.825571: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found 2022-09-16 15:28:17.827177: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303) 2022-09-16 15:28:17.838784: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: Sara 2022-09-16 15:28:17.839265: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: Sara RNN_OUT Shape: (None, 32, 6) WARNING:tensorflow:From C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\training\rmsprop.py:188: calling Ones.init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor Python: 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] Tensorflow: 2.9.2 2022-09-16 15:28:18.592158: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Init with stored values from ../model/snapshot-27 2022-09-16 15:28:18.672424: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:354] MLIR V1 optimization pass is not enabled Epoch: 1 Train NN 2022-09-16 15:28:20.101871: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at conv_grad_filter_ops.cc:450 : INVALID_ARGUMENT: Conv2DCustomBackpropFilter: filter and out_backprop must have the same out_depth Traceback (most recent call last): File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1377, in _do_call return fn(*args) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1360, in _run_fn return self._call_tf_sessionrun(options, feed_dict, fetch_list, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1453, in _call_tf_sessionrun return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict, tensorflow.python.framework.errors_impl.InvalidArgumentError: Conv2DCustomBackpropFilter: filter and out_backprop must have the same out_depth [[{{node gradients/convolution_grad/Conv2DBackpropFilter}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 166, in main() File "main.py", line 153, in main train(model, loader) File "main.py", line 44, in train loss = model.trainBatch(batch) File "C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py", line 214, in trainBatch (_, lossVal) = self.sess.run(evalList, feedDict) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 967, in run result = self._run(None, fetches, feed_dict, options_ptr, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1190, in _run results = self._do_run(handle, final_targets, final_fetches, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1370, in _do_run return self._do_call(_run_fn, feeds, fetches, targets, options, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1396, in _do_call raise type(e)(node_def, op, message) # pylint: disable=no-value-for-parameter tensorflow.python.framework.errors_impl.InvalidArgumentError: Graph execution error:

Detected at node 'gradients/convolution_grad/Conv2DBackpropFilter' defined at (most recent call last): File "main.py", line 166, in main() File "main.py", line 152, in main model = Model(loader.charList, decoderType) File "C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py", line 45, in init self.optimizer = tf.compat.v1.train.RMSPropOptimizer(self.learning_rate).minimize(self.loss) Node: 'gradients/convolution_grad/Conv2DBackpropFilter' Conv2DCustomBackpropFilter: filter and out_backprop must have the same out_depth [[{{node gradients/convolution_grad/Conv2DBackpropFilter}}]]

Original stack trace for 'gradients/convolution_grad/Conv2DBackpropFilter': File "main.py", line 166, in main() File "main.py", line 152, in main model = Model(loader.charList, decoderType) File "C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py", line 45, in init self.optimizer = tf.compat.v1.train.RMSPropOptimizer(self.learning_rate).minimize(self.loss) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\training\optimizer.py", line 477, in minimize grads_and_vars = self.compute_gradients( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\training\optimizer.py", line 603, in compute_gradients grads = gradients.gradients( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gradients_impl.py", line 165, in gradients return gradients_util._GradientsHelper( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gradients_util.py", line 695, in _GradientsHelper in_grads = _MaybeCompile(grad_scope, op, func_call, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gradients_util.py", line 328, in _MaybeCompile return grad_fn() # Exit early File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gradients_util.py", line 696, in lambda: grad_fn(op, *out_grads)) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\nn_grad.py", line 587, in _Conv2DGrad gen_nn_ops.conv2d_backprop_filter( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 1124, in conv2d_backpropfilter , _, _op, _outputs = _op_def_library._apply_op_helper( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\op_def_library.py", line 797, in _apply_op_helper op = g._create_op_internal(op_type_name, inputs, dtypes=None, File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\ops.py", line 3754, in _create_op_internal ret = Operation( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\ops.py", line 2133, in init self._traceback = tf_stack.extract_stack_for_node(self._c_op)

...which was originally created as op 'convolution', defined at: File "main.py", line 166, in main() [elided 0 identical lines from previous traceback] File "main.py", line 152, in main model = Model(loader.charList, decoderType) File "C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py", line 37, in init self.setupRNN() File "C:\Users\Harinath\Downloads\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\Devnagari-Handwritten-Word-Recongition-with-Deep-Learning-master\src\Model.py", line 93, in setupRNN self.rnnOut3d = tf.squeeze(tf.nn.atrous_conv2d(value=concat, filters=kernel, rate=1, padding='SAME'), axis=[2]) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\util\traceback_utils.py", line 150, in error_handler return fn(*args, kwargs) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\util\dispatch.py", line 1082, in op_dispatch_handler return dispatch_target(*args, *kwargs) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\nn_ops.py", line 1896, in atrous_conv2d return convolution( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\util\traceback_utils.py", line 150, in error_handler return fn(args, kwargs) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\util\dispatch.py", line 1082, in op_dispatch_handler return dispatch_target(*args, **kwargs) File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\nn_ops.py", line 1130, in convolution return convolution_internal( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\nn_ops.py", line 1282, in convolution_internal return op( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\nn_ops.py", line 2756, in _conv2d_expanded_batch return gen_nn_ops.conv2d( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gen_nnops.py", line 968, in conv2d , _, _op, _outputs = _op_def_library._apply_op_helper( File "C:\Users\Harinath\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\op_def_library.py", line 797, in _apply_op_helper op = g._create_op_internal(op_type_name, inputs, dtypes=None,