张量流模型的恢复保存程序.还原(sess,model_dir)在Google collaboratory失败了。在
恢复代码
tf.reset_default_graph()
sq_net = classifierNet(input_shape,out_classes,lr_rate,is_train)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
train_vars = tf.trainable_variables()
if model_dir is not None:
if os.path.exists("{}.index".format(model_dir)):
saver = tf.train.Saver()
saver.restore(sess, model_dir)
print("Model at %s restored" % model_dir)
else:
print("Model path does not exist, skipping...")
else:
print("Model path is None - Nothing to restore")
上述代码产生以下错误:
^{pr2}$安装驱动代码:
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
# Generate auth tokens for Colab
from google.colab import auth
auth.authenticate_user()
# Generate creds for the Drive FUSE library.
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
!mkdir -p dri
!google-drive-ocamlfuse dri
在googlecolab上训练了我的模型之后,我想保存它,然后为了测试目的而恢复它。我可以保存模型,但是restore函数在googlecolab中抛出了上面的错误(这在我的本地机器上运行)。请提出正确的方法。在
提前谢谢!在
使用文件id将模型文件下载到colab中。在
相关问题 更多 >
编程相关推荐