DiffSharp中的功能不可用



我使用以下F#脚本成功安装了DiffSharp(以及TorchSharp、Libsharp等(:

#r "nuget: DiffSharp.Core"
#r "nuget: DiffSharp.Backends.Reference"
#r "nuget: DiffSharp.Data"
#r "nuget: DiffSharp.Backends.Torch"
#r "nuget: TorchSharp"
#r "nuget: LibTorchSharp"
open System
open DiffSharp
open DiffSharp.Data
open DiffSharp.Model
open DiffSharp.Compose
open DiffSharp.Util
open DiffSharp.Optim

但是,以下功能不可用(根据DiffSharp API参考,应该可用(:

dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])

有什么想法吗?我是不是错过了任何图书馆或公开声明?

我不确定为什么这不起作用,但DiffSharp安装说明建议使用DiffSharp-cpu包(如果您已经有了LibTorch,则可以使用cudalite版本的包(,这对我来说很好:

#r "nuget: DiffSharp-cpu"
open DiffSharp
dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])

产品:

val x: Tensor =
tensor([[-1.5256, -0.7502, -0.6540, -1.6095, -0.1002], ...])

相关内容

  • 没有找到相关文章