2017-01-25 12:40:56 +00:00
|
|
|
xs = rand(20)
|
2017-01-25 11:33:58 +00:00
|
|
|
d = Affine(20, 10)
|
|
|
|
|
2017-02-20 20:09:05 +00:00
|
|
|
# MXNet
|
2017-01-26 18:32:59 +00:00
|
|
|
|
2017-02-21 12:58:31 +00:00
|
|
|
@mxonly let dm = mxnet(d, (20, 1))
|
2017-01-30 18:05:15 +00:00
|
|
|
@test d(xs) ≈ dm(xs)
|
2017-01-30 17:33:15 +00:00
|
|
|
end
|
|
|
|
|
2017-02-20 20:09:05 +00:00
|
|
|
@mxonly let
|
2017-02-21 15:46:38 +00:00
|
|
|
# TODO: test run
|
2017-02-20 20:09:05 +00:00
|
|
|
using MXNet
|
|
|
|
f = mx.FeedForward(Chain(d, softmax))
|
2017-02-21 15:46:38 +00:00
|
|
|
@test mx.infer_shape(f.arch, data = (20, 1))[2] == [(10, 1)]
|
|
|
|
|
|
|
|
m = Chain(Input(28,28), Conv2D((5,5), out = 3), MaxPool((2,2)),
|
|
|
|
flatten, Affine(1587, 10), softmax)
|
|
|
|
f = mx.FeedForward(m)
|
|
|
|
@test mx.infer_shape(f.arch, data = (20, 20, 5, 1))[2] == [(10, 1)]
|
2017-02-20 20:09:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# TensorFlow
|
|
|
|
|
|
|
|
@tfonly let dt = tf(d)
|
|
|
|
@test d(xs) ≈ dt(xs)
|
|
|
|
end
|
2017-01-26 18:32:59 +00:00
|
|
|
|
2017-02-01 07:11:17 +00:00
|
|
|
@tfonly let
|
|
|
|
using TensorFlow
|
2017-01-26 18:32:59 +00:00
|
|
|
|
|
|
|
sess = TensorFlow.Session()
|
|
|
|
X = placeholder(Float32)
|
|
|
|
Y = Tensor(d, X)
|
|
|
|
run(sess, initialize_all_variables())
|
2017-01-25 11:33:58 +00:00
|
|
|
|
2017-01-26 18:32:59 +00:00
|
|
|
@test run(sess, Y, Dict(X=>xs')) ≈ d(xs)'
|
|
|
|
end
|