Skip to content

ERROR: MethodError: objects of type Tuple{Dense.... } are not callable. #69

@kadir-gunel

Description

@kadir-gunel

Hello,

Trying to build a very basic example by using Flux and Torch. My WE contains the following packages:

The packages that I have :

  [052768ef] CUDA v5.6.1
  [587475ba] Flux v0.16.2
  [dbeba491] Metalhead v0.9.5
  [3bd65402] Optimisers v0.4.4
  [6a2ea274] Torch v0.1.3
  [e88e6eb3] Zygote v0.7.3
⌅ [4ee394cb] CUDA_Driver_jll v0.10.4+0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

Then I call CUDA and Torch packages :

julia> using CUDA
julia> using Torch

When I call Flux, it warns me about cuDNN. (Which I also installed but it gives some other error.)

julia> using Flux
┌ Warning: Package cuDNN not found in current path.
│ - Run `import Pkg; Pkg.add("cuDNN")` to install the cuDNN package, then restart julia.
│ - If cuDNN is not installed, some Flux functionalities will not be available when running on the GPU.
└ @ FluxCUDAExt ~/.julia/packages/Flux/BkG8S/ext/FluxCUDAExt/FluxCUDAExt.jl:10

Just a basic FFNN.

julia> net = Chain(
           Dense(10, 5, σ),
           Dense(5, 2),
           softmax)
Chain(
  Dense(10 => 5, σ),                    # 55 parameters
  Dense(5 => 2),                        # 12 parameters
  softmax,
)                   # Total: 4 arrays, 67 parameters, 476 bytes.

Then When I try to convert the model to torch, everything seems fine.

julia> torch_net = net.layers |> torch
(Dense(10 => 5, σ), Dense(5 => 2), softmax)

Preparing the input data.

julia>  ip = rand(Float32, 10);
julia> tip = tensor(ip, dev = 0)
10-element Tensor{Float32, 1}:
 0.17900974
 0.21817732
 0.35327947
 0.004907012
 0.34559655
 0.7998144
 0.5324366
 0.83601516
 0.8809979
 0.9549317

And giving the input to the model - torch_net produces :

julia> torch_net(tip)


ERROR: MethodError: objects of type Tuple{Dense{typeof(σ), Tensor{Float32, 2}, Tensor{Float32, 1}}, Dense{typeof(identity), Tensor{Float32, 2}, Tensor{Float32, 1}}, typeof(softmax)} are not callable
The object of type `Tuple{Dense{typeof(σ), Tensor{Float32, 2}, Tensor{Float32, 1}}, Dense{typeof(identity), Tensor{Float32, 2}, Tensor{Float32, 1}}, typeof(softmax)}` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
Stacktrace:
 [1] top-level scope
   @ REPL[25]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions