history = model.fit_generator(train_generator, epochs=epochs, steps_per_epoch=train_steps, verbose=1, callbacks=[checkpoint], validation_data=val_generator, validation_steps=val_steps)
def create_sequences(tokenizer, max_length, desc_list, photo, vocab_size):
X1, X2, y = list(), list(), list()
for desc in desc_list:
seq = tokenizer.texts_to_sequences([desc])[0]
for i in range(1, len(seq)):
in_seq, out_seq = seq[:i], seq[i] in_seq = pad_sequences([in_seq], maxlen=max_length)[0]
out_seq = to_categorical([out_seq], num_classes=vocab_size)[0]
X1.append(photo)
X2.append(in_seq)
y.append(out_seq)
return array(X1), array(X2), array(y)
def data_generator(descriptions, photos, tokenizer, max_length, imgsIds, vocab_size):
while 1:
for ind in range(len(imgsIds)):
photo = photos[ind]
key = imgsIds[ind]
desc_list = descriptions[str(key)]
in_img, in_seq, out_word = create_sequences( tokenizer, max_length, desc_list, photo, vocab_size) yield [in_img, in_seq], out_word

i got

82783/82783 [==============================] - ETA: 0s - loss: 4.0302Traceback (most recent call last):
File “rnn_flickr_fit.py”, line 281, in 
main(sys.argv)
File “rnn_flickr_fit.py”, line 278, in main
fit_model(train, train_descriptions, train_rnn_input, val, val_descriptions, val_rnn_input)
File “rnn_flickr_fit.py”, line 265, in fit_model
history = model.fit(train_generator, epochs=epochs, steps_per_epoch=train_steps, verbose=1, callbacks=[checkpoint], validation_data=val_generator, validation_steps=val_steps)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py”, line 1213, in fit
steps_per_execution=self._steps_per_execution)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py”, line 1364, in get_data_handler
return DataHandler(*args, **kwargs)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py”, line 1166, in init
model=model)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py”, line 811, in init
peek = _process_tensorlike(peek)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py”, line 1046, in _process_tensorlike
inputs = nest.map_structure(_convert_numpy_and_scipy, inputs)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/util/nest.py”, line 867, in map_structure
structure[0], [func(*x) for x in entries],
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/util/nest.py”, line 867, in 
structure[0], [func(*x) for x in entries],
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py”, line 1041, in _convert_numpy_and_scipy
return ops.convert_to_tensor_v2_with_dispatch(x, dtype=dtype)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py”, line 206, in wrapper
return target(*args, **kwargs)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 1431, in convert_to_tensor_v2_with_dispatch
value, dtype=dtype, dtype_hint=dtype_hint, name=name)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 1441, in convert_to_tensor_v2
as_ref=False)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/profiler/trace.py”, line 163, in wrapped
return func(*args, **kwargs)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 1566, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/tensor_conversion_registry.py”, line 52, in _default_conversion_function
return constant_op.constant(value, dtype, name=name)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py”, line 265, in constant
allow_broadcast=True)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py”, line 276, in _constant_impl
return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py”, line 301, in _constant_eager_impl
t = convert_to_eager_tensor(value, ctx, dtype)
File “/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py”, line 98, in convert_to_eager_tensor
return ops.EagerTensor(value, ctx.device_name, dtype)
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type dict).
2021-06-30 20:08:00.122545: W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
[[{{node PyFunc}}]]