我正在使用Tensorflow的mobilenet和以下代码。当我从本地PC运行此代码时,它将下载重量文件。但是,上传到服务器后,我无法在线下载该文件。
有什么办法可以将MobileNetV2与tensorflow 2.0一起使用?
或者,我有自己的配重文件,并且受MobielNetV2培训,那么可以在下面使用没有配重的选项
mobilenet = tf.keras.applications.mobilenet_v2.MobileNetV2(input_shape =(224,224,3),include_top = False,weights ='imagenet')
我想从Linux服务器使用supervisor。看来我需要使用绝对路径而不是相对路径。谁能帮助我在脱机环境中与主管一起使用MobileNetV2
您可以先使用:
mobilenet = tf.keras.applications.mobilenet_v2.MobileNetV2(input_shape=(224, 224, 3), include_top=False, weights='imagenet')
然后将权重保存在某处:
mobilenet.save_weights('somefolder/mobilenetweights.h5')
然后,当您离线时,您可以先致电:
mobilenet = tf.keras.applications.mobilenet_v2.MobileNetV2(input_shape=(224, 224, 3), include_top=False, weights=None)
注意None
inweights
参数。之后,您可以从以前保存的文件中加载权重:
mobilenet.load_weights('somefolder/mobilenetweights.h5')
这应该工作。
调用mobilenet模型时,如果要求使用来给它提供imagenet权重weights='imagenet'
,则需要Internet连接才能下载这些权重。因此它无法离线运行。此处说明的方法应使其起作用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句