You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified the housing example to use CuArray as shown below. The forward pass is OK but in the backward pass it causes ERROR: MethodError: no method matching next(::AutoGrad.Rec{CuArray{Float32,2}}, ::Tuple{Base.OneTo{Int64},Int64})
using Knet,CuArrays
include(Knet.dir("data","housing.jl"))
data =housing()
x,y = data
w = Any[ 0.1f0*cu(randn(Float32,1,13)), 0.0f0 ]
predict(w,x) = w[1]*x .+ w[2]
loss(w,x,y) =mean(abs2,y-predict(w,x))
loss(w,x,y) # 593.6816f0
lossgradient =grad(loss)
lossgradient(w,x,y) # Error: MethodError: no method matching next(::AutoGrad.Rec{CuArray{Float32,2}}, ::Tuple{Base.OneTo{Int64},Int64})functiontrain(w, data; lr=.1)
for d=data
x,y =cu.(d)
dw =lossgradient(w, x, y)
for i in1:length(w)
w[i] -= lr * dw[i]
endendreturn w
endfor i=1:10; train(w, [data]); println(loss(w,x,y)); end
The text was updated successfully, but these errors were encountered:
I modified the housing example to use CuArray as shown below. The forward pass is OK but in the backward pass it causes
ERROR: MethodError: no method matching next(::AutoGrad.Rec{CuArray{Float32,2}}, ::Tuple{Base.OneTo{Int64},Int64})
The text was updated successfully, but these errors were encountered: