'How do I find my trained model trained by "kaggle.com"

I trained a model use kaggle.com

The final code is:

history = model.fit(dataset, epochs=1)
model.save("/kaggle/working/039_model.h5")
print("Model saved successfully!")

The output is:

31368/31368 [==============================] - 23489s 749ms/step - loss: 1.4623
Model saved successfully!

For test, I just trained it for 1 epoch, but I cannot find my model in the /kaggle/working directory in the right side bar. Even if I click the refresh button or refresh the page.

The page picture is : my problem picture

Thanks for your help!



Solution 1:[1]

The refresh button of browser refreshes the whole environment that you were working on, all variables that were set, any file that were saved in storage instance allotted to you for that particular session.

You are given an instance of a server resource, i.e., RAM, few GB of temporary storage, CPU/GPU for a certain period of time. Refreshing the browser starts completely new instance losing all local changes to that instance.

So your model even though it might be saved in the local storage of that instance (on server), it will get deleted once that session expires (after 20 minutes of inactivity) or when you run out of quota or when you refreshes your page.

Solution is to don't refresh your page, look where the model is saved by exploring in side bar by clicking dropdown button and downloading the model for future use case.

Side Note: Committing your notebook will only commit, i.e., save that particular version of your code in the notebook, and will not save anything that you saved to the local storage of that instance, like in your case a saved model file.

Solution 2:[2]

Well, maybe I know what happend, I just find out I should save and run all.

File -> save version -> save & run all

so we can get all we want.

Solution 3:[3]

It is application manage, it will save on target directory except you using checkpoint callback !

    savedir = 'F:\\models\\save\\FlappyBird_15'
    checkpoint_path = "F:\\models\\checkpoint\\FlappyBird_15\\TF_DataSets_01.h5"

    if not exists(checkpoint_dir) : 
        os.mkdir(checkpoint_dir)
        print("Create directory: " + checkpoint_dir)

    ### model initialize ###
    model = tf.keras.models.Sequential([
    tf.keras.layers.InputLayer(input_shape=(1200, 1)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128, return_sequences=True, return_state=False)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128)),
    ])
    model.add(layers.Flatten())
    model.add(layers.Dense(64))
    model.add(layers.Dense(2))
    model.summary()
    ########################

    if exists(checkpoint_path) :
        model.load_weights(checkpoint_path)
        print("model load: " + checkpoint_path)
        input("Press Any Key!")

    model.save_weights(checkpoint_path)

Target checkpoints saved

Target validation  saved

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anurag Dhadse
Solution 2 Chuckie Zhu
Solution 3 Martijn Pieters