There is a newer version of this package available.
See the version list below for details.
dotnet add package Toro --version 0.2.2
                    
NuGet\Install-Package Toro -Version 0.2.2
                    
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.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Toro" Version="0.2.2" />
                    
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.2.2
                    
#r "nuget: Toro, 0.2.2"
                    
#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.2.2
                    
#: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.2.2
                    
Install as a Cake Addin
#tool nuget:?package=Toro&version=0.2.2
                    
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. Chain fallible operations with the result { } CE.

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 r = result {
    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
        opt.zeroGrad ()
        let! pred = model.forward x
        let! loss = Loss.mse pred y
        do! loss.backward ()
        do! 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. Arithmetic operators return Tensor directly. Shape and math methods return Result<Tensor, ToroError>.
  • 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, >=> Kleisli operator to build models without casts.
  • Training -- SGD, AdamW optimizers. MSE, cross-entropy, NLL, binary cross-entropy loss functions.
  • Error handling -- result { } CE with let! / do! for Result chaining.

Examples

Example Description
LinearRegression Gradient descent with raw tensors
SimpleTraining XOR with sequential { } CE
MnistTraining MLP on MNIST
MnistCnn CNN with BatchNorm, Dropout, Kleisli composition
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.GNN

Graph Neural Network layers for Toro

Toro.Vision

Image transforms for Toro

Toro.Text

Text tokenization bridge between Microsoft.ML.Tokenizers and Toro

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 0 8/14/2026
0.5.2 0 8/14/2026
0.4.0 66 8/11/2026
0.3.0 79 8/10/2026
0.2.2 104 8/10/2026
0.2.1 86 8/10/2026
0.1.3 80 8/8/2026
0.1.2 83 8/8/2026
0.1.1 80 8/8/2026
0.1.0 86 8/8/2026
0.0.2 89 8/4/2026
0.0.1 238 3/1/2024