【问题标题】:Tensorflow converting keras model for tensorflowjstensorflow 为 tensorflowjs 转换 keras 模型
【发布时间】:2018-10-08 20:06:10
【问题描述】:

使用标准代码 将张量流导入为 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)

我收到以下错误

文件“C:\Program Files\python36\lib\site-packages\tensorflow\python\client\session.py”,第 1321 行,在 _do_run 运行元数据)

文件“C:\Program Files\python36\lib\site-packages\tensorflow\python\client\session.py”,第 1340 行,在 _do_call raise type(e)(node_def, op, message)

FailedPreconditionError: 尝试使用未初始化的值 conv2d_98/kernel [[节点:_retval_conv2d_98/kernel_0_0 = _RetvalT=DT_FLOAT, index=0, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]]

【问题讨论】:

    标签: python tensorflow tensorflow.js


    【解决方案1】:

    您是否尝试过提供输入形状?

    例如

    if K.image_data_format() == 'channels_first':
        input_shape = (3, img_height, img_width)
    else:
        input_shape = (img_height, img_width, 3)
    

    其中img_height/width是你要预测的图片的大小

    【讨论】:

      猜你喜欢
      • 2019-10-13
      • 2020-01-15
      • 2021-04-08
      • 1970-01-01
      • 1970-01-01
      • 2019-05-14
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多