Merge pull request #41 from alha02/add-more-tf-ops
Add tf ops: svd, inv, det
This commit is contained in:
commit
0f433137d0
@ -27,9 +27,11 @@ graph(::typeof(max), x, dim=nothing) = TensorFlow.reduce_max(x;axis=dim)
|
|||||||
graph(::typeof(all), x, dim=nothing) = TensorFlow.reduce_all(x;axis=dim)
|
graph(::typeof(all), x, dim=nothing) = TensorFlow.reduce_all(x;axis=dim)
|
||||||
graph(::typeof(any), x, dim=nothing) = TensorFlow.reduce_any(x;axis=dim)
|
graph(::typeof(any), x, dim=nothing) = TensorFlow.reduce_any(x;axis=dim)
|
||||||
graph(::typeof(mean), x, dim=nothing) = TensorFlow.reduce_mean(x;axis=dim)
|
graph(::typeof(mean), x, dim=nothing) = TensorFlow.reduce_mean(x;axis=dim)
|
||||||
|
graph(::typeof(svd), x) = svd(x)
|
||||||
|
|
||||||
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,
|
||||||
|
inv, det)
|
||||||
@eval graph(::typeof($op), args...) = $op(args...)
|
@eval graph(::typeof($op), args...) = $op(args...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,4 +23,12 @@ test_anon(tf)
|
|||||||
@test run(sess, Y, Dict(X=>xs)) ≈ d(xs)
|
@test run(sess, Y, Dict(X=>xs)) ≈ d(xs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "Ops" begin
|
||||||
|
A = randn(Float32,(5,5))
|
||||||
|
u,s,v = tf(@net x -> svd(x))(A)
|
||||||
|
@test A ≈ u*diagm(s)*transpose(v)
|
||||||
|
@test tf(@net x -> inv(x))(A) ≈ inv(A)
|
||||||
|
@test tf(@net x -> det(x))(A) ≈ det(A)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user