Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

58 Commits

Repository files navigation

License

.NET

AndroidLinuxmacOSWindows

About

B# is a dynamically typed multi-paradigm programming language designed for writing high-level modules (like machine learning pipeline using ML.NET) in .NET applications.

C# 11 B#
usingSystem;usingtorch=System.AI.torch;usingnn=System.AI.torch.nn;usingF=System.AI.torch.nn.functional;usingoptim=System.AI.torch.optim;publicsealedclassLinearRegression:nn.Module{publicnn.Parameterweight;publicnn.Parameterbias;publicLinearRegression(){this.weight=newnn.Parameter(torch.randn());this.bias=newnn.Parameter(torch.randn());}publictorch.Tensorforward(torch.Tensorx){returnx*this.weight+this.bias;}}static(torch.Tensor,torch.Tensor)GetData(intbatch_size){return(torch.randn(batch_size),torch.randn(batch_size));}staticvoidMain(){varregr=newLinearRegression();varopt=newoptim.SGD(regr.parameters());for(intep=0;ep<epoch;++ep){(varinput,vartarget)=GetData();y=regr.op_Invocation(input);varloss=F.l1_loss(y,target);loss.backward();opt.step();Console.WriteLine(loss);}}
using*fromSystem;usingtorchfrom System.AI;usingnnfromSystem.AI.torch;usingfunctionalfromSystem.AI.torch.nnasF;usingoptimfromSystem.AI.torch;publicsealedclassLinearRegression:nn.Module{public:weight;bias;constructor(){this.weight=newnn.Parameter(torch.randn());this.bias=newnn.Parameter(torch.randn());}forward(x){returnx*this.weight+this.bias;}}get_data(batch_size){return(torch.randn(batch_size),torch.randn(batch_size));}main(){varregr=newLinearRegression();varopt=newoptim.SGD(regr.parameters());for(varep=0;ep<epoch;++ep){(varinput,vartarget)=GetData();y=regr(input);varloss=F.l1_loss(y,target);loss.backward();opt.step();Console.WriteLine(loss);}}

For more examples see B# vs C# vs Python

Compatibility

B# is compatible with given operating systems and .NET implementations:

OS.NET
MS Windows XP and higerMono 2.0, .NET Framework 4.0 and higer, .NET Core, .NET
Apple macOS 12.0 and higerMono 2.0, .NET Core, .NET
Linux (Mint, Ubuntu)Mono 2.0, .NET Core, .NET
Android 10 and higerMono 2.0

Development technology stack

  • Windows 7 x64
  • .NET Framework 4.5.2
  • C# 5
  • SharpDevelop 5.1 (IDE)
  • Jay (Parser generator)

About

New generation B programming language

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages