The Variational Autoencoder for collaborative filtering focuses on providing recommendations.
Quick Start Guide
To train your model using mixed or TF32 precision with Tensor Cores or using FP32, perform the following steps using the default parameters of the VAE-CF model on the MovieLens 20m dataset.
Login to NGC
Login to ngc before downloading the model from ngc resources.
docker login nvcr.io
Clone the Repository
Find resources related to this model in ngc/resources at: " https://ngc.nvidia.com/catalog/resources/nvidia:vae_for_tensorflow ". You can download resources manually from the top right part of the page or use wget resource command. These are four steps you need to pass to download and unzip resources by commandline:
- Make a new folder using mkdir command
- Go to the new folder using cd command
- Use the wget command to download resources as a zip file inside the folder.
- Unzip the zip file using unzip
mkdir VAE
cd VAE
wget --content-disposition https://api.ngc.nvidia.com/v2/resources/nvidia/vae_for_tensorflow/versions/20.06.0/zip -O vae_for_tensorflow_20.06.0.zip
unzip vae_for_tensorflow_20.06.0.zip
Build ngc Container
Run the next command to make a container using the Dockerfile inside the resource folder that you just downloaded. docker build . -t < tagname> You can tag the container with any name you want. Here we used vae tag.
docker build . -t vae
Run the Container
Run the next command to start the container. In this run command, we mounted a folder for data inside the container. We will download a movie rating dataset inside this folder. Beside, we set port 8888:8888 for this container so we can have access to a jupyterlab inside the container later using this port.
docker run -it --rm --runtime=nvidia -v /data/vae-cf:/data -p 8888:8888 vae /bin/bash
Dataset
We used the MovieLens 20m dataset. The VA-CF model was trained on the MovieLens 20M dataset. MovieLens 20M is a movie rating dataset. It includes 20 million ratings and 465,000 tag applications applied to 27,000 movies by 138,000 users. the goal of our model is to predict the rate of a new movie for a user considering the previous sets of (movie, rate) of the user. The model will be trained using a dataset of the movie and the rate for the movie. After that, the trained model predicts the rate of a new movie for a user.
If you do not have the dataset downloaded, run commands below to download and extract the MovieLens dataset to the /data/ml-20m/extracted/ folder.
The dataset can be preprocessed simply by running: python prepare_dataset.py in the Docker container. By default, the dataset will be stored in the /data directory. If you want to store the data in a different location, you can pass the desired location to the --data_dir argument.
mkdir /data/ml-20m
mkdir /data/ml-20m/extracted
wget http://files.grouplens.org/datasets/movielens/ml-20m.zip
unzip ml-20m.zip
If you already have the dataset downloaded and unzipped elsewhere, run the below commands to first exit the current VAE-CF Docker container and then restart the VAE-CF Docker Container by mounting the MovieLens dataset location.
exit
docker run -it --rm --gpus all -v /data/vae-cf:/data -v <ml-20m folder path>:/data/ml-20m/extracted/ml-20m -p 8888:8888 vae /bin/bash
Train and Test the Model Inside the Container
Now you have a running container and a dataset inside the container. We run the rest of commands using a jupyter notebook. Open the jupyterlab inside the container. After that, upload VAE-model notebook and run the cells of the notebook to train, test and inference this model.
jupyter notebook --ip 0.0.0.0 --port 8888 --allow-root