こすたろーんエンジニアの試行錯誤部屋

作成物の備忘録を書いていきますー

【pytorch】How to create a learning environment using the pytorch template

スポンサーリンク

I have been using the classyvision framework from pytoch to train my image classification model.
The framework is easy to use, but it is difficult to extend it by yourself...
I thought it would be possible to extend it with a template instead of a framework, so I looked for a template that looked good and tried it out.
This article is just a reminder.

contents

スポンサーリンク

abstract

How to create a learning environment using the pytorch template

1.requirement

1.1 requirement

Jetson Xavier NX
ubuntu18.04
docker
python3.6

1.2 Get Templates

The template used for this project is as follows
github.com

Clone from github with the following command

cd workspace
git clone https://github.com/victoresque/pytorch-template.git

1.3 create dockerfile&image

The dockerfile used this time is as follows

FROM nvcr.io/nvidia/l4t-pytorch:r32.4.4-pth1.6-py3

RUN pip3 install --upgrade pip
RUN pip3 install --ignore-installed PyYAML
RUN pip3 install tensorboard
RUN pip3 install pandas

Build

sudo docker build . -t pytorch_templete

1.4 run docker container

Start the docker container and enter the container

sudo docker run -it --rm --runtime nvidia -v /path/to/your/workspace/dir/:/workspace --workdir /workspace --network host pytorch_templete

2.sample run

Let's run the training of the image classification model using mnist and resnet this time.
The config.json file contains the above training by default, so we will use it as is.

python3 train.py -c config.json

The results of the evaluation after execution are as follows

    epoch          : 57
    loss           : 0.07924625007832926
    accuracy       : 0.9757558606973595
    top_k_acc      : 0.9974081753554502
    val_loss       : 0.03324085925061731
    val_accuracy   : 0.9901690729483283
    val_top_k_acc  : 0.999501329787234

Template-based learning is now available.

スポンサーリンク

3.refarence

github.com