add triangular_solve
This commit is contained in:
parent
015e373a34
commit
c8d320233a
@ -36,6 +36,7 @@ graph(::typeof(Flux.tile), args...) = TensorFlow.tile(args...)
|
|||||||
graph(::typeof(fill), x, dims) = Ops.fill(convert(Tensor{Int32}, dims), Tensor(x))
|
graph(::typeof(fill), x, dims) = Ops.fill(convert(Tensor{Int32}, dims), Tensor(x))
|
||||||
graph(::typeof(Flux.cast), args...) = TensorFlow.cast(args...)
|
graph(::typeof(Flux.cast), args...) = TensorFlow.cast(args...)
|
||||||
graph(::typeof(solve), A, b) = TensorFlow.matrix_solve(A, b)
|
graph(::typeof(solve), A, b) = TensorFlow.matrix_solve(A, b)
|
||||||
|
graph(::typeof(triangular_solve), A, b) = TensorFlow.matrix_triangular_solve(A, b; lower=false)
|
||||||
|
|
||||||
for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos,
|
for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos,
|
||||||
sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj,
|
sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export reshape, tile, fill, cast, solve
|
export reshape, tile, fill, cast, solve, triangular_solve
|
||||||
|
|
||||||
import Base: reshape, fill
|
import Base: reshape, fill
|
||||||
|
|
||||||
@ -7,3 +7,4 @@ tile(x::AbstractArray, mult::AbstractArray) = repeat(x,outer=tuple(mult...))
|
|||||||
fill{T}(x::T, dims::AbstractArray) = fill(x,tuple(dims...))
|
fill{T}(x::T, dims::AbstractArray) = fill(x,tuple(dims...))
|
||||||
cast{T}(x::AbstractArray, ::Type{T}) = convert(Array{T},x)
|
cast{T}(x::AbstractArray, ::Type{T}) = convert(Array{T},x)
|
||||||
solve(A::AbstractArray, b::AbstractArray) = A\b
|
solve(A::AbstractArray, b::AbstractArray) = A\b
|
||||||
|
triangular_solve(A::AbstractArray, b::AbstractArray) = A\b
|
||||||
|
@ -56,6 +56,8 @@ end
|
|||||||
A = randn(Float32,(5,5))
|
A = randn(Float32,(5,5))
|
||||||
b = randn(Float32,(5,1))
|
b = randn(Float32,(5,1))
|
||||||
@test tf(@net (x,y) -> solve(x,y))(A,b) ≈ A\b
|
@test tf(@net (x,y) -> solve(x,y))(A,b) ≈ A\b
|
||||||
|
_,A,_ = lu(A)
|
||||||
|
@test tf(@net (x,y) -> triangular_solve(x,y))(A,b) ≈ A\b
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user