【问题标题】:Batch size is 0 or NaN. Please choose a non-zero fraction批量大小为 0 或 NaN。请选择一个非零分数
【发布时间】:2019-01-22 07:03:03
【问题描述】:

在使用 tensorflow.js 时,我们正在添加图像进行训练,但在训练这些图像时出现错误。

        const gorra = new Image();
        gorra.src = "https://ml5js.org/docs/assets/img/bird.jpg";
        gorra.width = 224;
        gorra.height = 224;
        console.log("adding images DONE", gorra);

        img2 = new Image();
        img2.src = "{!$Resource.cat}"
        img2.width = 224;
        img2.height = 224;
        console.log(img2);

        console.log("setup classifier");

        console.log("adding example image...");
        const ex = await classifier.addImage(document.getElementById('imgshow'), "Gorra");
        console.log("adding ex image DONE!...", ex);
        const ex1 = await classifier.addImage(img2, "Gorra1");
        console.log("adding ex1 image DONE!...", ex1);

        console.log("Training");
        const trainer = await classifier.train();
        console.log("Training DONE", trainer);

请帮我找出这些图片添加到哪里以及为什么会出现错误。

塔克

【问题讨论】:

  • 可以分享分类器的train和addImage方法吗?

标签: javascript tensorflow artificial-intelligence


【解决方案1】:

我认为您的第二个图像源不正确,或者该图像未加载到内存中,并且您正在对一张图像进行训练,并且分类器需要至少 2 张图像用于训练目的。 另请参阅: https://github.com/ml5js/ml5-library/issues/212

【讨论】:

  • 是的,我尝试了超过 2 个图像集。这行得通,但它再次卡在 Mobilenet.js 的 train() 方法上。上面写着'Uncaught (in promise) TypeError: t is not a function'
  • 很难用这个提供的代码找出你的问题。你能分享初始化分类器变量的代码吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-13
  • 2012-11-21
  • 2017-09-27
  • 2018-07-14
  • 2021-05-31
相关资源
最近更新 更多