-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
derivation of Tensor.matmul
Issue #437 | Created by @psiLearn | 2022-08-31 08:35:33 UTC |
My Example is this short code:
#r "nuget: DiffSharp-cpu"
open DiffSharp
open DiffSharp.Model
let createStiffnessFunction m c d =
fun (x:Tensor) ->
(dsharp.tensor [[0.; 1.];[-c; -d]]).matmul(x)
let f = createStiffnessFunction 0.5 1000. 0.5
let df = dsharp.diff f
f (dsharp.tensor [0.001; 0.])
df (dsharp.tensor [0.001; 0.])
I get this error message. Is it not possible to derive the result of a matmul?
System.Exception: f must be a function of a scalar, encountered f:[|2|]->[|2|]
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\a\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439
at DiffSharp.dsharp.fdiff(FSharpFunc`2 f, Tensor x)
at DiffSharp.dsharp.diff(FSharpFunc`2 f, Tensor x)
at <StartupCode$FSI_0096>.$FSI_0096.main@()
Metadata
Metadata
Assignees
Labels
No labels