Reputation: 771
I try to get reproducible results in Google Colab by using the following code. But I get the error "NameError: name 'session_conf' is not defined".
import numpy as np
import tensorflow as tf
import random as rn
import os
os.environ['PYTHONHASHSEED']='0'
np.random.seed(1)
rn.seed(1)
from keras import backend as K
if 'tensorflow' == K.backend():
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = true
config.gpu_options.allow_growth = True
config.gpu_options.visible_device_liste = "0"
set_session(tf.Session(config=config))
tf.set_random_seed(1)
sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)
K.set_session(sess)
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
Has anyone an idea of the reasons why?
Upvotes: 1
Views: 1331
Reputation: 314
You haven't declared the variable session_conf
in line sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)
.
Upvotes: 1