Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations #1

Merged
merged 1 commit into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
### Evaluate the model

```julia
correct_prediction = indmax(y, 2) .== indmax(y_, 2)
correct_prediction = argmax(y, 2) .== argmax(y_, 2)
accuracy=reduce_mean(cast(correct_prediction, Float32))
testx, testy = load_test_set()

Expand Down Expand Up @@ -137,7 +137,7 @@ cross_entropy = reduce_mean(-reduce_sum(y_.*log(y_conv), axis=[2]))

train_step = train.minimize(train.AdamOptimizer(1e-4), cross_entropy)

correct_prediction = indmax(y_conv, 2) .== indmax(y_, 2)
correct_prediction = argmax(y_conv, 2) .== argmax(y_, 2)

accuracy = reduce_mean(cast(correct_prediction, Float32))

Expand Down
2 changes: 1 addition & 1 deletion examples/mnist_full.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

train_step = train.minimize(train.AdamOptimizer(1e-4), cross_entropy)

correct_prediction = indmax(y_conv, 2) .== indmax(y_, 2)
correct_prediction = argmax(y_conv, 2) .== argmax(y_, 2)

accuracy = reduce_mean(cast(correct_prediction, Float32))

Expand Down
2 changes: 1 addition & 1 deletion examples/mnist_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ y = nn.softmax(x*W + b)
cross_entropy = reduce_mean(-reduce_sum(y_ .* log(y), axis=[2]))
train_step = train.minimize(train.GradientDescentOptimizer(.00001), cross_entropy)

correct_prediction = indmax(y, 2) .== indmax(y_, 2)
correct_prediction = argmax(y, 2) .== argmax(y_, 2)
accuracy=reduce_mean(cast(correct_prediction, Float32))

for i in 1:1000
Expand Down
1 change: 0 additions & 1 deletion src/TensorFlow.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__precompile__(true)
module TensorFlow

@warn("Loading a new version of TensorFlow.jl for the first time. This initial load can take around 5 minutes as code is precompiled; subsequent usage will only take a few seconds.")
Expand Down
8 changes: 4 additions & 4 deletions src/generate_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Returns `true` if the given operation attribute is not meant to be supplied
by the user and `false` otherwise.
"""
function is_internal_arg(arg)
arg._type == "type" && ismatch(r"^T", arg.name)
arg._type == "type" && occursin(r"^T", arg.name)
end

function to_function(op::tensorflow.OpDef)
Expand Down Expand Up @@ -174,7 +174,7 @@ function to_function(op::tensorflow.OpDef)
end
end)
end
unshift!(inputs, kwargs)
pushfirst!(inputs, kwargs)
scalar_output = true
if length(op.output_arg) > 1
scalar_output = false
Expand Down Expand Up @@ -257,7 +257,7 @@ stringify_func(op::tensorflow.OpDef) = stringify_func(to_function(op))
function load_default_imports()
path = joinpath(@__DIR__, "../deps/default_imports.txt")
names = readlines(path)
filtered = [name for name in names if !ismatch(r"^#", name)]
filtered = [name for name in names if !occursin(r"^#", name)]
return filtered
end

Expand Down Expand Up @@ -328,7 +328,7 @@ Returns a reference to a Julia function corresponding to the operation.
function import_op(name)
jl_name = opname_to_jlname(name)
mod = TensorFlow.Ops
if jl_name ∉ names(mod, true)
if jl_name ∉ names(mod, all=true)
ops = Dict(get_all_op_list())
op = ops[name]
op_desc = to_function(op)
Expand Down
6 changes: 3 additions & 3 deletions src/shape_inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Base.copy(shape::TensorShape) = TensorShape(copy(shape.dims), shape.rank_unknown

function Base.broadcast!(s1::TensorShape, s2::TensorShape)
while length(s1.dims) < length(s2.dims)
unshift!(s1.dims, Nullable(1))
pushfirst!(s1.dims, Nullable(1))
end
while length(s2.dims) < length(s1.dims)
unshift!(s2.dims, Nullable(1))
pushfirst!(s2.dims, Nullable(1))
end
s1, s2
end
Expand Down Expand Up @@ -261,7 +261,7 @@ function load_const(op)
catch err
if isa(err, tf.EmptyTensorError)
T = eltype(Tensor(op, 1))
value = Array{T}(0)
value = Array{T}(undef, 0)
else
rethrow(err)
end
Expand Down
4 changes: 2 additions & 2 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ end

function open_url(url)
cmd = nothing
if is_apple()
if Sys.isapple()
cmd = `open $url`
elseif is_unix()
elseif Sys.isunix()
cmd = `xdg-open $url`
end
cmd === nothing || run(cmd)
Expand Down
2 changes: 1 addition & 1 deletion src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ end
tf.get_tensors(v::Variable) = [v.var_node]

function is_variable(name::AbstractString)
return ismatch(r"^(Variable|VariableV\d+)$", name)
return occursin(r"^(Variable|VariableV\d+)$", name)
end

is_variable(name::Union{tf.Operation, tf.AbstractTensor}) = is_variable(tf.get_op(name).op_name)
Expand Down
2 changes: 1 addition & 1 deletion test/clipping.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

sess = TensorFlow.Session(TensorFlow.Graph())
a_raw = rand(10, 10)
Expand Down
6 changes: 3 additions & 3 deletions test/comp.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

sess = TensorFlow.Session(TensorFlow.Graph())
a_raw = collect(1:5)
Expand Down Expand Up @@ -28,5 +28,5 @@ result = run(sess, TensorFlow.select(cond_tf, a, b))
@test [1; 7; 3; 4; 10] == result


@test run(sess, find(constant([true,true, false,true]))) == [1 2 4]'
@test run(sess, find(constant([true true false true; false true false true]))) == [1 1; 1 2; 1 4; 2 2; 2 4]
@test run(sess, findall(constant([true,true, false,true]))) == [1 2 4]'
@test run(sess, findall(constant([true true false true; false true false true]))) == [1 1; 1 2; 1 4; 2 2; 2 4]
2 changes: 1 addition & 1 deletion test/control.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test
using TensorFlow


Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test
using TensorFlow
const tf = TensorFlow

Expand Down
2 changes: 1 addition & 1 deletion test/debug.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

sess = TensorFlow.Session()

Expand Down
2 changes: 1 addition & 1 deletion test/hello.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

# Try your first TensorFlow program
# https://github.com/tensorflow/tensorflow#try-your-first-tensorflow-program
Expand Down
2 changes: 1 addition & 1 deletion test/image.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

sess = TensorFlow.Session(TensorFlow.Graph())

Expand Down
2 changes: 1 addition & 1 deletion test/init_ops.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test


sess = Session(Graph())
Expand Down
2 changes: 1 addition & 1 deletion test/io.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

mktempdir() do dirname
filename = joinpath(dirname, "tfrecords")
Expand Down
14 changes: 7 additions & 7 deletions test/math.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

sess = TensorFlow.Session(TensorFlow.Graph())

Expand Down Expand Up @@ -89,15 +89,15 @@ end

a_raw = rand(10)
a = TensorFlow.constant(a_raw)
result = run(sess, indmin(a, 1))
@test indmin(a_raw) == result
result = run(sess, indmax(a, 1))
@test indmax(a_raw) == result
result = run(sess, argmin(a, 1))
@test argmin(a_raw) == result
result = run(sess, argmax(a, 1))
@test argmax(a_raw) == result

#check it find the first instance of lowest/highers number as the result for indmin/indmax
x=constant([1 2 3; 0 2 3; 0 0 3; 0 0 0]')
@test [2, 3, 4] == run(sess, indmin(x, 2))
@test [1, 1, 1] == run(sess, indmax(x, 2))
@test [2, 3, 4] == run(sess, argmin(x, 2))
@test [1, 1, 1] == run(sess, argmax(x, 2))
end

@testset "logic" begin
Expand Down
2 changes: 1 addition & 1 deletion test/meta.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test
using TensorFlow
using Distributions

Expand Down
4 changes: 2 additions & 2 deletions test/nn.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test
using StatsFuns

@testset "conv2d_transpose" begin
Expand All @@ -17,7 +17,7 @@ end


@testset "Cross Entropy Loss" begin
srand(1)
Random.seed!(1)
let
sess = Session(Graph())
targets = constant(collect(1:10))
Expand Down
2 changes: 1 addition & 1 deletion test/ops.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test


@testset "Importing" begin
Expand Down
4 changes: 2 additions & 2 deletions test/run.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test
using TensorFlow

@testset "Placeholder Size Matching" begin
Expand Down Expand Up @@ -37,7 +37,7 @@ using TensorFlow
end

@testset begin
srand(1)
Random.seed!(1)
data = rand(Int64.(1:10), 3,4)
sess = Session(Graph())

Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using TensorFlow
using Base.Test
using Test

srand(0) # Make tests deterministic
Random.seed!(0) # Make tests deterministic

include(joinpath(dirname(@__FILE__), "..", "examples", "logistic.jl"))

Expand Down
4 changes: 2 additions & 2 deletions test/sequences.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

sess = Session(Graph())

Expand All @@ -12,7 +12,7 @@ sess = Session(Graph())
x = random_normal(shape, dtype=dtype)
@test get_shape(x) == TensorShape(shape)
result = run(sess, x)
@test size(result) == (shape...)
@test size(result) == (shape...,)
@test eltype(result) == dtype
end
end
14 changes: 7 additions & 7 deletions test/shape_inference.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

k = placeholder(Float32; shape=[10, 20, -1])
m = placeholder(Float32; shape=[10, 20, 30])
Expand Down Expand Up @@ -56,9 +56,9 @@ end
end

@testset "Find (i.e Where)" begin
@test get_shape(find(placeholder(Bool; shape=[10, 20, 30]))) == TensorShape([-1,3])
@test get_shape(find(placeholder(Bool; shape=[10, 20, -1]))) == TensorShape([-1,3])
@test get_shape(find(placeholder(Bool))) == TensorShape(nothing)
@test get_shape(findall(placeholder(Bool; shape=[10, 20, 30]))) == TensorShape([-1,3])
@test get_shape(findall(placeholder(Bool; shape=[10, 20, -1]))) == TensorShape([-1,3])
@test get_shape(findall(placeholder(Bool))) == TensorShape(nothing)
end

@testset "Stack/Unstack" begin
Expand Down Expand Up @@ -92,7 +92,7 @@ end


@testset "ArgMinMax" begin
@testset "$f" for f in (indmin, indmax, Ops.arg_min, Ops.arg_max)
@testset "$f" for f in (argmin, argmax, Ops.arg_min, Ops.arg_max)
@test get_shape(f(k, 1)) == TensorShape([20, -1])
@test get_shape(f(k, 2)) == TensorShape([10, -1])
@test get_shape(f(k, 3)) == TensorShape([10, 20])
Expand Down Expand Up @@ -180,8 +180,8 @@ end
(m, i, nothing)
]
# test commutativeness
@test get_shape(select(c, a1, a2)) == TensorShape(r)
@test get_shape(select(c, a2, a1)) == TensorShape(r)
@test get_shape(partialsort(c, a1, a2)) == TensorShape(r)
@test get_shape(partialsort(c, a2, a1)) == TensorShape(r)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/show.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

@testset "Tensorboard" begin
TensorFlow.get_tensorboard()
Expand Down
2 changes: 1 addition & 1 deletion test/summary.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using TensorFlow
const tf = TensorFlow
using Base.Test
using Test

graph = Graph()
sess = Session(graph)
Expand Down
2 changes: 1 addition & 1 deletion test/train.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test

@testset "save and resore" begin
try
Expand Down
2 changes: 1 addition & 1 deletion test/training.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test
using TensorFlow

@testset "Training with 'gather' nodes" begin
Expand Down
4 changes: 2 additions & 2 deletions test/transformations.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TensorFlow
using Base.Test
using Test


sess = TensorFlow.Session(TensorFlow.Graph())
Expand Down Expand Up @@ -149,7 +149,7 @@ end
# Tests after this point must provide their own sessions and graphs

@testset "Concatenation Syntax" begin
srand(37)
Random.seed!(37)
sess4 = Session(Graph())

a_jl = rand(10,5); a = constant(a_jl);
Expand Down