Flux.jl/test/backend/tensorflow.jl

33 lines
620 B
Julia
Raw Normal View History

2017-02-23 22:28:18 +00:00
using TensorFlow
Flux.loadtf()
@testset "TensorFlow" begin
2017-04-18 20:04:21 +00:00
xs = rand(1, 20)
2017-02-23 22:28:18 +00:00
d = Affine(20, 10)
dt = tf(d)
@test d(xs) dt(xs)
@testset "Tensor interface" begin
sess = TensorFlow.Session()
X = placeholder(Float32)
Y = Tensor(d, X)
2017-04-27 11:48:11 +00:00
run(sess, global_variables_initializer())
2017-02-23 22:28:18 +00:00
2017-04-18 20:04:21 +00:00
@test run(sess, Y, Dict(X=>Float32.(xs))) d(xs)
2017-02-23 22:28:18 +00:00
end
2017-03-12 18:34:11 +00:00
@testset "Stack Traces" begin
model = TLP(Affine(10, 20), Affine(21, 15))
dm = tf(model)
2017-04-18 20:04:21 +00:00
e = try dm(rand(1, 10))
2017-03-12 18:34:11 +00:00
catch e e end
@test isa(e, DataFlow.Interpreter.Exception)
@test e.trace[1].func == Symbol("Flux.Affine")
@test e.trace[2].func == :TLP
end
2017-02-23 22:28:18 +00:00
end