Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the default download directory for pre-trained model in Keras?

According to documentation, it says that the default download directory for all Keras files is $HOME/.keras. I'm using virtual environment and I want to change the default download directory of pre-trained models to a different directory. Maybe this has more to do with virtualenv than with Keras?

like image 779
Sunil Avatar asked Mar 01 '18 17:03

Sunil


People also ask

What is the default configuration file for keras?

The Keras configuration file is a JSON file stored at $HOME/.keras/keras.json. The default configuration file looks like this: The image data format to be used as default by image processing layers and utilities (either channels_last or channels_first ). The epsilon numerical fuzz factor to be used to prevent division by zero in some operations.

How do I save a keras model to disk?

There are two formats you can use to save an entire model to disk: the TensorFlow SavedModel format, and the older Keras H5 format . The recommended format is SavedModel. It is the default when you use model.save (). You can switch to the H5 format by: Passing save_format='h5' to save (). Passing a filename that ends in .h5 or .keras to save ().

Where are keras data files stored?

This is legacy; nowadays there is only TensorFlow. Likewise, cached dataset files, such as those downloaded with get_file (), are stored by default in $HOME/.keras/datasets/ , and cached model weights files from Keras Applications are stored by default in $HOME/.keras/models/. How to do hyperparameter tuning with Keras?

How can I use pre-trained models in keras?

How can I use pre-trained models in Keras? You could leverage the models available in keras.applications, or the models available on TensorFlow Hub . TensorFlow Hub is well-integrated with Keras. How can I use stateful RNNs?


1 Answers

If you are using the master branch of keras, you can set the KERAS_HOME environment variable to set the cache directory. If it is not set, cache directory defaults to $HOME/.keras.

export KERAS_HOME="/path/to/keras/dir"

Add the line to your ".bashrc" to set the variable every time you open up a new terminal.

This has not yet been released, you must use the master branch to use this feature.

like image 156
Fauzan Avatar answered Oct 28 '22 19:10

Fauzan