dotnet 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" />
                    
Directory.Packages.props
<PackageReference Include="Toro" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=Toro&version=0.4.0
                    
Install as a Cake Tool

Toro

Toro Toro.NN Toro.GNN Toro.Text Toro.Vision

PyTorch semantics, idiomatic F#. Powered by TorchSharp.

Define models with F# records and computation expressions. Use scoped { } to manage tensor lifetimes automatically.

Documentation

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], and t.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 { } and pipeline { } 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

MIT

Product 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.

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.

Version Downloads Last Updated
0.4.0 49 8/11/2026
0.3.0 64 8/10/2026
0.2.2 88 8/10/2026
0.2.1 84 8/10/2026
0.1.3 79 8/8/2026
0.1.2 82 8/8/2026
0.1.1 79 8/8/2026
0.1.0 85 8/8/2026
0.0.2 88 8/4/2026
0.0.1 238 3/1/2024