[英]Tensorflow converting keras model for tensorflowjs
Using standard code import tensorflow as tf import tensorflowjs as tfjs 使用标准代码将tensorflow导入为tf将tensorflowjs导入为tfjs
tfjs_target_dir = 'c:/files'
model = tf.keras.applications.InceptionV3(
include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000
)
tfjs.converters.save_keras_model(model, tfjs_target_dir)
I get the following error 我收到以下错误
File "C:\\Program Files\\python36\\lib\\site-packages\\tensorflow\\python\\client\\session.py", line 1321, in _do_run run_metadata) 文件“ C:\\ Program Files \\ python36 \\ lib \\ site-packages \\ tensorflow \\ python \\ client \\ session.py”,行1321,在_do_run run_metadata中)
File "C:\\Program Files\\python36\\lib\\site-packages\\tensorflow\\python\\client\\session.py", line 1340, in _do_call raise type(e)(node_def, op, message) 文件“ C:\\ Program Files \\ python36 \\ lib \\ site-packages \\ tensorflow \\ python \\ client \\ session.py”,行1340,在_do_call中引发类型(e)(node_def,op,message)
FailedPreconditionError: Attempting to use uninitialized value conv2d_98/kernel [[Node: _retval_conv2d_98/kernel_0_0 = _RetvalT=DT_FLOAT, index=0, _device="/job:localhost/replica:0/task:0/device:CPU:0"]] FailedPreconditionError:尝试使用未初始化的值conv2d_98 / kernel [[节点:_retval_conv2d_98 / kernel_0_0 = _RetvalT = DT_FLOAT,索引= 0,_device =“ / job:localhost /副本0 /任务:0 /设备:CPU:0”]]
Have you tried to provide an input shape? 您是否尝试提供输入形状?
eg 例如
if K.image_data_format() == 'channels_first':
input_shape = (3, img_height, img_width)
else:
input_shape = (img_height, img_width, 3)
with img_height/width is the size of the pictures you want to predict img_height / width是您要预测的图片大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.