Giter Club home page Giter Club logo

pytorchnet's Introduction

Welcome to PyTorchNet!

PyTorchNet is a Machine Learning framework that is built on top of PyTorch. And, it uses Tensorboard (or Visdom) for visualization.

PyTorchNet is easy to be customized by creating the necessary classes:

  1. Data Loading: a dataset class is required to load the data.
  2. Model Design: a nn.Module class that represents the network model.
  3. Loss Method: an appropriate class for the loss, for example CrossEntropyLoss or MSELoss.
  4. Evaluation Metric: a class to measure the accuracy of the results.

Structure

PyTorchNet consists of HAL library which has the following packages:

HAL/Datasets

This is for loading and transforming datasets.

HAL/Models

Network models are kept in this package. It already includes ResNet, PreActResNet, Stacked Hourglass and SphereFace.

HAL/Losses

There are number of different choices available for Classification or Regression. New loss methods can be put here.

HAL/Metrics

There are number of different choices available for Classification or Regression. New accuracy metrics can be put here.

Root

  • main
  • model

Setup

First, you need to download PyTorchNet by calling the following command:

git clone https://github.com/human-analysis/pytorchnet.git

PyTorchNet relies on several Python packages, such as Pytorch, Pytorch Lightning, tensorboard, Pillow Image, etc. you need to make sure that the requirements exist.

Notice

  • If you do not have Pytorch or it does not meet the requirements, please follow the instruction on the Pytorch website.

Congratulations!!! You are now ready to use PyTorchNet!

Usage

PyTorchNet comes with a classification example in which a ResNet model is trained for the CIFAR10 dataset.

python main.py

Configuration

PyTorchNet loads its parameters at the beginning via a config file and/or the command line.

Config file

When PyTorchNet is being run, it will automatically load all parameters from args.txt by default, if it exists. In order to load a custom config file, the following parameter can be used:

python main.py --config custom_args.txt

args.txt

[Arguments] save_results = No

#project options
project_name=CIFAR10
save_dir=results/
logs_dir=results/

#dataset options
dataset=CIFAR10
dataroot=data/
cache_size=1000

#model options
precision=32
batch_size_test = 128
batch_size_train = 128
model_type = MobileNetV2
loss_type = Classification
evaluation_type = Accuracy

resolution_high = 32
resolution_wide = 32

manual_seed = 0
nepochs = 200

optim_method = SGD
learning_rate = 0.1
optim_options = {"momentum": 0.9, "weight_decay": 5e-4}

scheduler_method = CosineAnnealingLR
scheduler_options = {"T_max": 200}

#cpu/gpu settings
ngpu = 1
nthreads = 4

Command line

Parameters can also be set in the command line when invoking main.py. These parameters will precede the existing parameters in the configuration file.

python main.py --visualizer VisualizerTensorboard

pytorchnet's People

Contributors

rahmatkhah avatar vboddeti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorchnet's Issues

Visdom JSON error

I'm getting the following error when trying to run python main.py (using pytorch 4.1 and visdom 0.1.8.5):

Traceback (most recent call last):
  File "/home/michael/miniconda2/envs/pt/lib/python3.6/site-packages/visdom/__init__.py", line 446, in _send
    data=json.dumps(msg),
  File "/home/michael/miniconda2/envs/pt/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/home/michael/miniconda2/envs/pt/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/home/michael/miniconda2/envs/pt/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/michael/miniconda2/envs/pt/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'Scatter' is not JSON serializable

Imagenet training

What is the expected structure of ImageNet dataset? I'm trying to pass train folder with folder per class train jpg images, and val folder with all 50k validation images. But it's not clear how to pass labels for val examples using datasets.ImageFolder in dataloader.py.

"Adam" optimization

For "Adam" optimization method, "betas = (.., ..)" can not be set when I try to use "args.txt"
The error I am getting is:
ValueError: too many values to unpack (expected 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.