Toro 0.4.0
Prefix Reserveddotnet add package Toro --version 0.4.0
NuGet\Install-Package Toro -Version 0.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Toro" Version="0.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Toro" Version="0.4.0" />
<PackageReference Include="Toro" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Toro --version 0.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Toro, 0.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Toro@0.4.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Toro&version=0.4.0
#tool nuget:?package=Toro&version=0.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Toro
PyTorch semantics, idiomatic F#. Powered by TorchSharp.
Define models with F# records and computation expressions.
Use scoped { } to manage tensor lifetimes automatically.
Installation
dotnet add package Toro
dotnet add package Toro.NN
dotnet add package TorchSharp-cpu
Quick Example
Train a two-layer network on the XOR problem:
open Toro
open Toro.NN
let x = Tensor.ofList ([ [ 0f; 0f ]; [ 0f; 1f ]; [ 1f; 0f ]; [ 1f; 1f ] ], Cpu)
let y = Tensor.ofList ([ [ 0f ]; [ 1f ]; [ 1f ]; [ 0f ] ], Cpu)
let l1 = Linear.init 2 16 F32 Cpu
let l2 = Linear.init 16 1 F32 Cpu
let model = sequential { l1; Relu; l2 }
let opt = AdamW.createWithLr 0.01 (Model.trainableVars model)
for epoch in 1..500 do
scoped {
opt.zeroGrad ()
let pred = model.forward x
let loss = Loss.mse pred y
loss.backward ()
opt.step ()
if epoch % 100 = 0 then
printfn "epoch %d loss=%.6f" epoch (loss.item ())
}
Features
- Tensor API -- Create, reshape, index, and compute with tensors. Methods and operators throw on failure for concise method chaining.
- Ownership management --
scoped { }CE automatically disposes intermediate tensors. Return values are kept alive past the scope. - Indexing --
t[0],t[0..2], andt.at [ I 1; S(0, 3) ]for advanced patterns. - Neural network layers -- Linear, Conv1d/Conv2d, Embedding, LSTM, GRU, BatchNorm, Dropout, LayerNorm, MultiHeadAttention, TransformerBlock.
- Composition --
sequential { }andpipeline { }CEs to build models without casts. - Training -- SGD, AdamW optimizers. MSE, cross-entropy, NLL, binary cross-entropy loss functions.
Examples
| Example | Description |
|---|---|
| LinearRegression | Gradient descent with raw tensors |
| SimpleTraining | XOR with sequential { } CE |
| MnistTraining | MLP on MNIST |
| MnistCnn | CNN with BatchNorm, Dropout |
| MnistAutoencoder | Autoencoder with image output |
| MnistGan | GAN image generation |
| CharRnn | Character-level text generation with LSTM |
| TextClassifier | Transformer-based text classification |
| SimpleGcn | GNN node classification with GCNConv |
| HubSentiment | Load DistilBERT from Hugging Face Hub |
Development
Build and run tests:
dotnet build
dotnet test
Preview the documentation site locally:
cd docs
pnpm install
pnpm dev
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- FSharp.Core (>= 10.1.302)
- TorchSharp (>= 0.107.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Toro:
| Package | Downloads |
|---|---|
|
Toro.NN
Neural network building blocks for Toro |
|
|
Toro.Vision
Image transforms for Toro |
|
|
Toro.Text
Text tokenization bridge between Microsoft.ML.Tokenizers and Toro |
|
|
Toro.GNN
Graph Neural Network layers for Toro |
GitHub repositories
This package is not used by any popular GitHub repositories.