Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Tried to convert 'x' to a tensor and failed. Error: Cannot create a tensor proto whose content is larger than 2GB. #4

Open
lxyzler opened this issue Aug 22, 2019 · 4 comments

Comments

@lxyzler
Copy link

lxyzler commented Aug 22, 2019

Traceback (most recent call last):
File "train.py", line 95, in
training_model.fit_generator(train_generator, steps_per_epoch=int(train_generator.nb_samples / train_generator.batch_size), epochs=cfg.nb_epochs, verbose=1, workers=cfg.nb_workers, use_multiprocessing=True, callbacks=callbacks)
File "/home/sherry/.local/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/sherry/.local/lib/python3.6/site-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/home/sherry/.local/lib/python3.6/site-packages/keras/engine/training_generator.py", line 223, in fit_generator
callbacks.on_batch_end(batch_index, batch_logs)
File "/home/sherry/.local/lib/python3.6/site-packages/keras/callbacks.py", line 115, in on_batch_end
callback.on_batch_end(batch, logs)
File "/home/sherry/CRNN-master/utils.py", line 130, in on_batch_end
accuracy, correct_char_predictions = self.evaluate()
File "/home/sherry/CRNN-master/utils.py", line 162, in evaluate
ctc_decode = K.ctc_decode(y_pred[:, 2:, :], input_length=np.ones(shape[0])*shape[1])[0][0]
File "/home/sherry/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 4289, in ctc_decode
y_pred = tf.log(tf.transpose(y_pred, perm=[1, 0, 2]) + epsilon())
File "/usr/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1420, in transpose
ret = transpose_fn(a, perm, name=name)
File "/usr/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8927, in transpose
"Transpose", x=x, perm=perm, name=name)
File "/usr/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 528, in _apply_op_helper
(input_name, err))

how to solve the problem?

@lxyzler lxyzler changed the title How to make the lexicon file? ValueError: Tried to convert 'x' to a tensor and failed. Error: Cannot create a tensor proto whose content is larger than 2GB. Aug 28, 2019
@janzd
Copy link
Owner

janzd commented Aug 29, 2019

What are the specs of the machine you use? Particularly the GPU.
And tell me your TF and Keras version too, please.

@lxyzler
Copy link
Author

lxyzler commented Aug 29, 2019 via email

@janzd
Copy link
Owner

janzd commented Aug 30, 2019

I haven't tested it with TF 1.12 and Keras version higher than 2.2, but I think it should work with those versions too.
How large is your input? This error indicates that it tried to initialize a variable larger than 2 GB, which doesn't work by default. https://stackoverflow.com/questions/51470991/create-a-tensor-proto-whose-content-is-larger-than-2gb

It uses Synth90k annotation. There is a file, let's call it annotation.txt, that contains paths to images and the IDs of the words in those images. Example:

img/wither.jpg 4
img/illager.jpg 1
img/ENDER.jpg 2
img/vindicator.jpg 5
img/PILLAGER.jpg 0
img/evoker.jpg 3

Then, you have a file lexicon.txt where all words (in your case sequences of Chinese characters) are stored. The above-mentioned IDs correspond to line numbers in this file (the first line is 0).

PILLAGER
illager
ENDER
evoker
wither
vindicator

If you'd rather use your format, which I like better than the Synth90k format actually, you'd have rewrite the data loading part of the code.

@lxyzler
Copy link
Author

lxyzler commented Aug 31, 2019

I have rewrite the data_generator
File "/home/sherry/CRNN-master/utils.py", line 162, in evaluate
ctc_decode = K.ctc_decode(y_pred[:, 2:, :], input_length=np.ones(shape[0])*shape[1])[0][0]

I try the Synth90k,in this case,y_pred[:, 2:, :].shape is (5000, 48, 37)
if l use my dataset,the shape is (5000, 48, 5990),because l have 5990 Chinese characters
Does this cause problems?y_pred[:, 2:, :] can not be too large?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants