/JuliaTorch

Using PyTorch in Julia Language

Primary LanguageJulia

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