October 2019
Intermediate to advanced
444 pages
10h 37m
English
Only a few steps are needed to train and use a neural network in Rust:
[dependencies]tch = "0.1"failure ="0.1"
use std::io::{Error, ErrorKind};use std::path::Path;use std::time::Instant;use tch::{nn, nn::ModuleT, nn::OptimizerConfig, Device, Tensor};
#[derive(Debug)]struct ConvNet { conv1: nn::Conv2D, conv2: nn::Conv2D, fc1: nn::Linear, fc2: nn::Linear,}impl ConvNet { fn new(vs: &nn::Path, labels: i64) -> ConvNet { ConvNet { conv1: nn::conv2d(vs, 1, 32, 5, ...