Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 本地TFJS模型(迁移学习MobileNet)返回错误的预测_Tensorflow_Expo_Tensorflow.js - Fatal编程技术网

Tensorflow 本地TFJS模型(迁移学习MobileNet)返回错误的预测

Tensorflow 本地TFJS模型(迁移学习MobileNet)返回错误的预测,tensorflow,expo,tensorflow.js,Tensorflow,Expo,Tensorflow.js,我使用MobileNet的迁移学习来解决图像问题。我用ImageDataGenerator(rescale=1./127.5)加载了图像 培训后,我将其转换为: tensorflowjs_converter --input_format=tf_saved_model --weight_shard_size_bytes 10000000000 model tmp 下一步是在我的Expo应用程序中加载我的模型和体重文件: const model = await tf.loadGraphModel(

我使用MobileNet的迁移学习来解决图像问题。我用ImageDataGenerator
(rescale=1./127.5)
加载了图像

培训后,我将其转换为:

tensorflowjs_converter --input_format=tf_saved_model --weight_shard_size_bytes 10000000000 model tmp
下一步是在我的Expo应用程序中加载我的模型和体重文件:

const model = await tf.loadGraphModel(bundleResourceIO(modelJson,modelWeight));
并规范化我的输入图像:

const normalized  = imageTensor.toFloat().sub(127.5).div(127.5);
输出完全错误(一个类始终为1,其他所有类始终为0)


有人知道问题可能是什么吗?

通过此规范化解决了问题:

const normalized  = imageTensor.toFloat().sub(127).div(128);

尝试使用
1./127.5-1
重新缩放。MobileNet希望图像的范围为(-1,1)。@Frightera如下:imageTensor.toFloat().div(127.5).sub(1)?不起作用,但:/