forked from tracel-ai/burn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[guide] Remove ambiguity lib vs. executable (tracel-ai#1649)
- Loading branch information
Showing
9 changed files
with
169 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
use burn::{ | ||
backend::{wgpu::AutoGraphicsApi, Autodiff, Wgpu}, | ||
data::dataset::Dataset, | ||
optim::AdamConfig, | ||
}; | ||
use guide::{model::ModelConfig, training::TrainingConfig}; | ||
// | ||
// Note: If you are following the Burn Book guide this file can be ignored. | ||
// | ||
// This example file is added only for convenience and consistency so that | ||
// the guide example can be executed like any other examples using: | ||
// | ||
// cargo run --release --example guide | ||
// | ||
use std::process::Command; | ||
|
||
fn main() { | ||
type MyBackend = Wgpu<AutoGraphicsApi, f32, i32>; | ||
type MyAutodiffBackend = Autodiff<MyBackend>; | ||
|
||
let device = burn::backend::wgpu::WgpuDevice::default(); | ||
let artifact_dir = "/tmp/guide"; | ||
guide::training::train::<MyAutodiffBackend>( | ||
artifact_dir, | ||
TrainingConfig::new(ModelConfig::new(10, 512), AdamConfig::new()), | ||
device.clone(), | ||
); | ||
guide::inference::infer::<MyBackend>( | ||
artifact_dir, | ||
device, | ||
burn::data::dataset::vision::MnistDataset::test() | ||
.get(42) | ||
.unwrap(), | ||
); | ||
Command::new("cargo") | ||
.args(["run", "--bin", "guide"]) | ||
.status() | ||
.expect("guide example should run"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
mod data; | ||
mod inference; | ||
mod model; | ||
mod training; | ||
|
||
use crate::{model::ModelConfig, training::TrainingConfig}; | ||
use burn::{ | ||
backend::{wgpu::AutoGraphicsApi, Autodiff, Wgpu}, | ||
data::dataset::Dataset, | ||
optim::AdamConfig, | ||
}; | ||
|
||
fn main() { | ||
type MyBackend = Wgpu<AutoGraphicsApi, f32, i32>; | ||
type MyAutodiffBackend = Autodiff<MyBackend>; | ||
|
||
let device = burn::backend::wgpu::WgpuDevice::default(); | ||
let artifact_dir = "/tmp/guide"; | ||
crate::training::train::<MyAutodiffBackend>( | ||
artifact_dir, | ||
TrainingConfig::new(ModelConfig::new(10, 512), AdamConfig::new()), | ||
device.clone(), | ||
); | ||
crate::inference::infer::<MyBackend>( | ||
artifact_dir, | ||
device, | ||
burn::data::dataset::vision::MnistDataset::test() | ||
.get(42) | ||
.unwrap(), | ||
); | ||
} |