我正在尝试重用tensorflow创建的tensorflowjs模型。为了理解转换器是如何工作的,我尝试转换mobilenetv2模型:
tensorflowjs_converter --input_format=tf_hub --output_format=tensorflowjs 'https://tfhub.dev/google/imagenet/mobilenet_v2_050_224/classification/2' ./web_model这似乎很管用。然后,我尝试通过更改模型的加载方式在mobilenet demo中使用这个新的转换后的模型:
// const model = await mobilenet.load({version, alpha});
// replaced by
const model = await mobilenet.load({ modelUrl: './web_model/model.json', version, alpha, inputRange: [0, 1], fromTFHub: true });
// Classify the image.
const predictions = await model.classify(img);classify调用会触发错误:
Uncaught (in promise) Error: Activation relu6 has not been implemented for the WebGL backend.我不知道官方的tensorflowjs mobilenet模型是如何生成的:(
发布于 2019-09-13 20:28:29
from keras.applications import MobileNetV2
model = MobileNetV2(weights='imagenet', include_top=False)
save_model(
model,
"mobilenet2.h5",
overwrite=True,
)将mobilenet特征提取器转换为js
tensorflowjs_converter --input_format keras \
path/to/mobilenet2.h5 \
path/to/tfjs_target_dir发布于 2019-09-18 10:33:37
relu6的运算符是1周前才添加的。它应该在下一个TensorFlow.js版本中可用。
请在最新版本发布后尝试使用。
发布于 2019-10-05 04:22:18
这个问题与新版本无关。我也有同样的问题,一直在绕圈子。如果您使用的是GPU运行时(我使用的是Colab GPU运行时),则会发生此问题。你只需要在CPU模式下拟合/fit_generate模型,你的模型就会在happy状态下准备就绪。
https://stackoverflow.com/questions/57920601
复制相似问题