简体   繁体   中英

Tensorflow CPU-only:TypeError: unbound method _as_graph_element() must be called with Variable instance as first argument

I use Tensorflow without GPU, only CPU. I installed it with pip install tensorflow . My Ubuntu17 has Python3, but when I pip install tensorflow , It uses Python2.

My code look like this:

h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)

I get this error.

TypeError: unbound method _as_graph_element() must be called with Variable instance as first argument (got nothing instead)
[Finished in 2.2s with exit code 1]

What does this mean? Now I'm trying to use python3 instead, could that help?

It is really difficult to understand the error without the context. Maybe your dimensions for either of x_image or W_conv1 are wrong. Maybe you forgot to initialize the weights?

You are more likely to get answers if you add a bit of context (reproducible if possible) code.

Edit: install pip3 and do pip3 install package to install python3 packages (if this is also a part of your question)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM