【发布时间】:2018-06-20 07:32:15
【问题描述】:
我正在查看来自tfjs 的 tensorflow.js CNN 示例。
测试仓库可以在这里找到:testing repo。
有什么方法可以从每一层获取输出?
async showPredictions() {
const testExamples = 1;
// const testExamples = 100;
const batch = this.data.nextTestBatch(testExamples);
tf.tidy(() => {
const output: any = this.model.predict(batch.xs.reshape([-1, 28, 28, 1]));
output.print();
const axis = 1;
const labels = Array.from(batch.labels.argMax(axis).dataSync());
const predictions = Array.from(output.argMax(axis).dataSync());
// ui.showTestResults(batch, predictions, labels);
});
}
以上是 tfjs 示例中的预测方法,但只打印了最后一层。如何在预测中从每一层(包括卷积层、最大池化层和完全连接层)获取输出?
【问题讨论】:
标签: javascript tensorflow machine-learning deep-learning tensorflow.js