Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow 2.1.0 Error, module 'tensorflow' has no attribute 'GraphKeys'

I just installed new tf and cuda today, but when I run the previous code that worked with tf-1.4 won't work under new tensorflow-2.1.0 and cuda-10.1

How to fix this?

like image 404
Jason Avatar asked Jan 24 '20 03:01

Jason


1 Answers

Mentioning the Solution in the Answer Section (even though it is present in Comments Section), for the benefit of the Community.

Replacing the command,

import tensorflow as tf

with

import tensorflow.compat.v1 as tf

has resolved the error.

For more information about Migrating from Tensorflow 1.x to 2.x, please refer this Tensorflow Tutorial and this Upgrade Script also will be helpful.

like image 74
Tensorflow Support Avatar answered Nov 14 '22 00:11

Tensorflow Support