• Stars
    star
    70
  • Rank 432,798 (Top 9 %)
  • Language
    Julia
  • Created over 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Using PyTorch in Julia Language

JuliaTorch

Using PyTorch in Julia Language via PyCall.

Requirement

  • Julia >= 1.0
  • PyTorch >= 1.0 with Python 3 (Anaconda3 is recommended)
  • PyCall >= 1.19

You can tell PyCall.jl which Python you would like to use by exporting PYTHON environment variable in your .bashrc or .zshrc, e.g., if I wish to use the Python in Anaconda3 I can add the line

export PYTHON="/home/xiucheng/anaconda3/bin/python"

You may consider install this chrome extension to read the equations in this repository.

Roadmap

Usage

The codes can be run in command line or Jupyter notebook. For example,

$ julia vae.jl --nepoch 15

Miscell

Defining PyTorch nn.Module in Julia

@pydef mutable struct Model <: nn.Module
    function __init__(self, ...)
        pybuiltin(:super)(Model, self).__init__()
        self.f = ...
    end
    function forward(self, x)
      self.f(x)
    end
end