make tf model running easier

This commit is contained in:
Mike J Innes 2017-01-25 18:10:56 +05:30
parent 770b74fe5f
commit 8db503eafa
4 changed files with 6 additions and 3 deletions

View File

@ -53,7 +53,7 @@ function runmodel(m::Model, args...)
end
function (m::Model)(args::Batch...)
runmodel(m, args...)
runmodel(m, map(x -> convertel(Float32, x), args)...)
end
function (m::Model)(args...)

View File

@ -1,7 +1,7 @@
module TF
using ..Flux, DataFlow, TensorFlow, Juno
import Flux: accuracy, rebatch
import Flux: accuracy, rebatch, convertel
export tf

View File

@ -1,5 +1,8 @@
export onehot, onecold, chunk, partition, batches, sequences
convertel(T::Type, xs::AbstractArray) = map(x->convert(T, x), xs)
convertel{T}(::Type{T}, xs::AbstractArray{T}) = xs
"""
onehot('b', ['a', 'b', 'c', 'd']) => [false, true, false, false]

View File

@ -1,4 +1,4 @@
xs = rand(Float32, 20)
xs = rand(20)
d = Affine(20, 10)