2017-02-23 22:28:18 +00:00
|
|
|
using TensorFlow
|
|
|
|
Flux.loadtf()
|
|
|
|
|
|
|
|
@testset "TensorFlow" begin
|
|
|
|
|
2017-05-01 15:12:46 +00:00
|
|
|
xs, ys = rand(1, 20), rand(1, 20)
|
2017-02-23 22:28:18 +00:00
|
|
|
d = Affine(20, 10)
|
|
|
|
|
|
|
|
dt = tf(d)
|
|
|
|
@test d(xs) ≈ dt(xs)
|
|
|
|
|
2017-05-04 12:52:31 +00:00
|
|
|
test_tupleio(tf)
|
|
|
|
test_recurrence(tf)
|
|
|
|
test_stacktrace(tf)
|
2017-05-30 16:23:34 +00:00
|
|
|
test_anon(tf)
|
2017-05-01 17:05:17 +00:00
|
|
|
|
2017-02-23 22:28:18 +00:00
|
|
|
@testset "Tensor interface" begin
|
|
|
|
sess = TensorFlow.Session()
|
|
|
|
X = placeholder(Float32)
|
2017-06-05 15:32:16 +00:00
|
|
|
Y = Flux.TF.astensor(d, X)
|
2017-04-27 11:48:11 +00:00
|
|
|
run(sess, global_variables_initializer())
|
2017-02-23 22:28:18 +00:00
|
|
|
|
2017-05-01 17:27:52 +00:00
|
|
|
@test run(sess, Y, Dict(X=>xs)) ≈ d(xs)
|
2017-02-23 22:28:18 +00:00
|
|
|
end
|
|
|
|
|
2017-06-08 05:05:31 +00:00
|
|
|
@testset "Ops" begin
|
|
|
|
|
|
|
|
error_margin = 1e-4
|
|
|
|
|
|
|
|
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
# svd
|
|
|
|
A = convert(Array{Float32},randn(5,5))
|
|
|
|
@net f(x) = svd(x)
|
|
|
|
m = tf(f)
|
|
|
|
u,s,v = m(A)
|
|
|
|
@test maximum(abs.(u*diagm(s)*transpose(v) - A)) < error_margin
|
|
|
|
|
|
|
|
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2017-02-23 22:28:18 +00:00
|
|
|
end
|