When using tensorflow.keras, this error is often reported during model training:
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}}]]
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}}]]
According to my own experience, there are several reasons for this errory:
1. The input image_size and input_shape does not match or is not defined when the model is built. Note that the input_shape must be defined when defining the first layer of the convolutional layer, e.g.
model = keras.models.Sequential([
# Input image [None,224,224,3]
# Convolution layer 1: 32 5*5*3 filters, step size set to 1, fill set to same
# Output [None,32,32,3]
keras.layers.Conv2D(32, kernel_size=5, strides=1, padding='same', data_format='channels_last',
activation='relu', input_shape=(224, 224, 3)),
2. There is also train_generator and validate_generator related parameters must be consistent, such as batch_size, target_size, class_mode, etc.
3. The configuration limit itself, try to change the batch_size to a smaller size, or even to 1
4. The last program did not finish completely, finish all python programs to see.
Read More:
- [Solved] Python Keras Error: AttributeError: ‘Sequential‘ object has no attribute ‘predict_classes‘
- To solve the problem that the loss of verification set of resnet50 pre-training model remains unchanged
- Error:output with shape [1, 224, 224] doesn‘t match the broadcast shape [3, 224, 224]
- [Solved] R Error: Python module tensorflow.keras was not found.
- [Solved] Python Error: An attempt has been made to start a new process before the current process has finished …
- [Solved] YOLOv4 Error: Layer before convolutional layer must output image.: No error
- Python: RNN principle realized by numpy
- Pytorch ValueError: Expected more than 1 value per channel when training, got input size [1, 768
- AttributeError: can‘t set attribute [How to Solve]
- How to Solve keras load_model() Error
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- ModuleNotFoundError: No module named ‘tensorflow.python’ And the pits encountered after installation
- [Solved] torchsummary Error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.F
- [Solved] RuntimeError: Error(s) in loading state_dict for Net:
- Conda Install Library Error: failed with initial frozen solve. Retrying with flexible solve.
- Facenet validate_on_lfw.py Error AssertionError: The number of LFW images must be an integer multip
- [Solved] RuntimeError: cublas runtime error : resource allocation failed at
- Python custom convolution kernel weight parameters
- Python Kmeans Error: ConvergenceWarning: Number of distinct clusters (99) found smaller than n_clusters (100).
- [Solved] AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘AdampOptimizer‘