Skip to content

04_01_gan_camel_train.ipynb getting "TypeError: cannot pickle '_thread.RLock' object" #89

@rohan-paul

Description

@rohan-paul

In file 04_01_gan_camel_train.ipynb the following code block gives error

gan.train(     
    x_train
    , batch_size = BATCH_SIZE
    , epochs = EPOCHS
    , run_folder = RUN_FOLDER
    , print_every_n_batches = PRINT_EVERY_N_BATCHES
)

Getting TypeError: cannot pickle '_thread.RLock' object

I have tried to implement the changes from this PR by changing the GAN.py per this PR. But still getting the same error.

Specifically, even though I am deleting this below line

pkl.dump(self, open(os.path.join(run_folder, "obj.pkl"), "wb"))

Still, the file obj.pkl (of 0 bytes) is getting generated and producing this error.

Same error coming on the tensorflow_2 branch.

For helping with possible sources of the problem, refer this Stackoverflow link, which says

Generally pickle has problems saving ml model weights for pytorch, tensorflow and keras. To save your keras model, check out their tutorials

specifically, try using the functions save and load_module in keras:

model.save('path/to/location')
reconstructed_model = keras.models.load_model("path/to/location")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions