美文网首页
CUP密集型 如何优化

CUP密集型 如何优化

作者: 旧时袋 | 来源:发表于2021-01-16 14:31 被阅读0次

采用 setTimeout( () => { }, 0) 能将 CUP计算密集的部分放到 下一轮再运行

setTimeout(() => {
      // 模型预测
      const pred = tf.tidy(() => {
          const x = img2x(img);
          return this.model.predict(x);
      })

     // 将结果转换为 易读数组
     const results = pred.arraySync()[0]
         .map((score, i) => ({
          score, label: this.CLASSES[i]
     }))
     .sort((a, b) => b.score - a.score);
            
     console.log(results);
}, 0);

相关文章

网友评论

      本文标题:CUP密集型 如何优化

      本文链接:https://www.haomeiwen.com/subject/nsynaktx.html