在经过Google Cloud ML训练的Rstudio中加载tensorflow SavedModel [英] Load tensorflow SavedModel in Rstudio trained in Google Cloud ML

查看:65
本文介绍了在经过Google Cloud ML训练的Rstudio中加载tensorflow SavedModel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google Cloud ML中训练了一个模型,并将其保存为已保存的模型格式.我已经在下面附加了已保存模型的目录.

I trained a model in Google Cloud ML and saved it as a saved model format. I've attached the directory for the saved model below.

https://drive.google.com/drive/folders /18ivhz3dqdkvSQY-dZ32TRWGGW5JIjJJ1?usp = sharing

我正在尝试使用以下代码将模型加载到R中,但是它返回的<tensorflow.python.training.tracking.tracking.AutoTrackable>的对象大小为552字节,显然是不正确的.如果任何人都可以正确加载模型,我很想知道您是如何做到的.我认为它也应该能够加载到python中,这也可以工作.该模型是在GPU上训练的,不确定是哪个tensorflow版本.非常感谢你!

I am trying to load the model into R using the following code but it is returning <tensorflow.python.training.tracking.tracking.AutoTrackable> with an object size of 552 bytes, definetly not correct. If anyone can properly load the model, I would love to know how you did it. It should also be able to be loaded into python I assume, that could work too. The model was trained on GPU, not sure which tensorflow version. Thank you very much!

library(keras)

list.files("/path/to/inceptdual400OG")
og400<-load_model_tf("/path/to/inceptdual400OG")

推荐答案

由于共享模型不再可用(它说是在回收站文件夹中),并且在我无法告诉哪个框架的问题中未指定您曾经将模型保存在第一位.我建议尝试 Keras加载功能

Since the shared model is not available anymore (it says that is in the trash folder)and it is not specified in the question I can't tell which framework you used to save the model on first place. I will suggest trying the Keras load function or the Tensorflow load function depending on which type of saved file model you have. Bear in mind modify this argument as "compile = FALSE" if you have the model already compiled.

如果您使用tf> = 2.0训练模型,请记住要导入最新的库,因为依赖项不兼容{ Tensorflow Keras }和rsconnect :: appDependencies()输出将值得检查.

Remember to import the latest libraries if you trained your model with tf>=2.0 because of dependencies incompatibilities {Tensorflow, Keras} and rsconnect::appDependencies() output would be worth checking.

这篇关于在经过Google Cloud ML训练的Rstudio中加载tensorflow SavedModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆