Migrating from Pytorch

knitr::opts_chunk$set(echo = TRUE,eval = FALSE,echo = T)

_

Plain Pytorch with fastai

library(fastai)
library(magrittr)

data = Data_Loaders(train_loader, test_loader)

nn = nn()
learn = Learner(data, Net(), loss_func = nn$functional$nll_loss, 
                opt_func = Adam(), metrics = accuracy, cbs = CudaCallback())

learn %>% fit_one_cycle(1, 1e-2)


Try the fastai package in your browser

Any scripts or data that you put into this service are public.

fastai documentation built on March 31, 2023, 11:41 p.m.