TypeError: ‘TensorVariable’ object is not callable

846 views
Skip to first unread message

Abder-Rahman Ali

unread,
Jul 10, 2016, 3:37:43 PM7/10/16
to Keras-users

I'm following this tutorial. The code version I currently have can be found here.

When I try to run the code, I get the following:

Using Theano backend.
Traceback (most recent call last):
File hypercolumn.py”, line 85, in
get_feature = theano.function([model.layers[0].input], model.layers[3].output(train=False), allow_input_downcast=False)
TypeError: TensorVariable object is not callable

How can I solve this issue?

Thanks.

François Chollet

unread,
Jul 10, 2016, 7:11:45 PM7/10/16
to Abder-Rahman Ali, Keras-users
Instead of:

model.layers[3].output(train=False)
model.layers[3].output

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/b2c2f24d-bb54-4436-9732-fa191d719e82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abder-Rahman Ali

unread,
Jul 10, 2016, 7:30:03 PM7/10/16
to Keras-users, abder.ra...@gmail.com
Thanks a lot for your kind reply.

The line now looks as follows:

get_feature = theano.function([model.layers[0].input], model.layers[3].output, allow_input_downcast=False)

But, I keep getting the same error:

Using Theano backend.
Traceback (most recent call last):
  File "hypercolumn.py", line 104, in <module>
    hc = extract_hypercolumn(model, layers_extract, im)
  File "hypercolumn.py", line 90, in extract_hypercolumn
    layers = [model.layers[li].output(train=False) for li in layer_indexes]

TypeError: 'TensorVariable' object is not callable

Am I missing something?

Thanks.

Carlos Bentes

unread,
Jul 11, 2016, 4:02:40 AM7/11/16
to Keras-users, abder.ra...@gmail.com
You got the same error, try to apply the same fix ;)

In other words, you should also change the code at line 90.

Cheers,
cb
Reply all
Reply to author
Forward
0 new messages