Tue, 13 Apr 2021 15:51:28 -0500
Fix Linops to use AbstractMatrix instead of Matrix
| 21 | 1 | module DifferentiableFN |
| 2 | ||
| 3 | using ..LinOps | |
| 4 | ||
|
25
90f92ee9cb81
Add basic Func to DifferentiableFN
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
5 | export Func, |
|
90f92ee9cb81
Add basic Func to DifferentiableFN
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
6 | DiffF, |
| 21 | 7 | value, |
| 8 | differential, | |
| 9 | adjoint_differential | |
| 10 | ||
|
25
90f92ee9cb81
Add basic Func to DifferentiableFN
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
11 | abstract type Func{X,Y} end |
|
90f92ee9cb81
Add basic Func to DifferentiableFN
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
12 | abstract type DiffF{X,Y,T} <: Func{X, Y} end |
| 21 | 13 | |
|
25
90f92ee9cb81
Add basic Func to DifferentiableFN
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
14 | function value(f :: F, x :: X) :: Y where {X, Y, F <: Func{X,Y}} |
| 21 | 15 | @error "`value` unimplemented" |
| 16 | end | |
| 17 | ||
| 18 | # function (f :: D)(x::X) where {X, Y, T <: LinOp{X, Y}, D <: DiffF{X, Y, T}} | |
| 19 | # return value(x) | |
| 20 | # end | |
| 21 | ||
| 22 | function differential(f :: DiffF{X,Y,T}, x :: X) :: T where {X, Y, T <: LinOp{X, Y}} | |
| 23 | @error "`differential` unimplemented" | |
| 24 | end | |
| 25 | ||
| 26 | function adjoint_differential(f :: DiffF{X,Y,T}, x :: X) :: T where {X, Y, T <: LinOp{X, Y}} | |
| 27 | @error "`adjoint_differential` unimplemented" | |
| 28 | end | |
| 29 | ||
| 30 | function adjoint_differential(f :: DiffF{X,Y, T}, x :: X) :: T where {X, Y, T <: AdjointableOp{X, Y}} | |
| 31 | return AdjointOp(differential(f, x)) | |
| 32 | end | |
| 33 | ||
| 34 | end |