TensorFlow.jl
TensorFlow.jl copied to clipboard
MNIST Tutorial Fails
Both the MNIST softmax regression model and the multi-layer convolutional network fail with accuracies of 0.0
.
Interestingly, both the Basic usage and Logistic regression examples seem to work fine.
In addition, with my libtensorflow.so
, both mnist_softmax.py and mnist_deep.py from TensorFlow's Python examples work fine with Python 2.7 and Python 3.6.
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e2ff (2017-10-24 22:15 UTC)
Platform Info:
OS: Linux (x86_64-redhat-linux)
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, skylake)
julia> Pkg.installed("TensorFlow")
v"0.7.5"
julia> tf_version()
v"1.4.0"
...
for i in 1:1000
batch = next_batch(loader, 50)
if i%100 == 1
train_accuracy = run(session, accuracy, Dict(x=>batch[1], y_=>batch[2], keep_prob=>1.0))
info("step $i, training accuracy $train_accuracy")
end
run(session, train_step, Dict(x=>batch[1], y_=>batch[2], keep_prob=>.5))
end
testx, testy = load_test_set()
test_accuracy = run(session, accuracy, Dict(x=>testx, y_=>testy, keep_prob=>1.0))
info("test accuracy $test_accuracy")
INFO: step 1, training accuracy 0.0
INFO: step 101, training accuracy 0.0
INFO: step 201, training accuracy 0.0
INFO: step 301, training accuracy 0.0
INFO: step 401, training accuracy 0.0
INFO: step 501, training accuracy 0.0
INFO: step 601, training accuracy 0.0
INFO: step 701, training accuracy 0.0
INFO: step 801, training accuracy 0.0
INFO: step 901, training accuracy 0.0
INFO: test accuracy 0.0
I ran into a similar issue, and traced it down to the following. The tutorial gives this line of code:
julia> correct_prediction = indmax(y,2) .== indmax(y_, 2)
false
But as you can see, this doesn't return a Tensor
but the constant value false
. The intended line seems to have been:
julia> correct_prediction = equal(indmax(y,2), indmax(y_, 2))
<Tensor Equal:1 shape=unknown dtype=Bool>
and indeed, this allows me to reproduce the stated accuracy for the softmax model.
Recent changes to .
and broadcast
may be to blame, but I haven't dug into that (yet).
Thoughts?
Ah ya, that's possible. A PR fixing the documentation would be welcome.
I ran into a similar issue, and traced it down to the following. The tutorial gives this line of code:
julia> correct_prediction = indmax(y,2) .== indmax(y_, 2) false But as you can see, this doesn't return a Tensor but the constant value false. The intended line seems to have been:
julia> correct_prediction = equal(indmax(y,2), indmax(y_, 2)) <Tensor Equal:1 shape=unknown dtype=Bool> and indeed, this allows me to reproduce the stated accuracy for the softmax model.
Recent changes to . and broadcast may be to blame, but I haven't dug into that (yet).
Thoughts?
Or is the true intention to overload ==
? ... Or something like:
julia> import Base.==
julia> ==(x::T, y::T) where T<:TensorFlow.Tensor = equal(x, y)
== (generic function with 275 methods)
Same issue reported at #364 .