我已經(jīng)按照TensorFlow.js自述文件中的說明訓(xùn)練并生成了文件但是當(dāng)我預(yù)測時,它是行不通的<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs/dist/tf.min.js"></script><div> <h1 id="p">Try Tensorflow</h1> <p>model.json</p><input type="file" id="upload-json" /> <p>weight.bin</p><input type="file" id="upload-weights" /> <button type="button" id="myBtn" onclick="myFunction()">Try it</button> <script> function myFunction() { const uploadJSONInput = document.getElementById('upload-json'); const uploadWeightsInput = document.getElementById('upload-weights'); console.log('start'); tf.tensor([ [1, 2], [3, 4] ]).print(); //no issues umtill here const model = tf.loadLayersModel(tf.io.browserFiles( [uploadJSONInput.files[0], uploadWeightsInput.files[0]] )).then(() => { console.log('will print now'); model.predict(tf.tensor2d([5], [1, 1])).print(); }); console.log(model.predict(tf.tensor2d([5], [1, 1])).print()); } </script></div>我應(yīng)該改變些什么來使其預(yù)測?
無法通過在tensorflow.js中加載預(yù)訓(xùn)練的模型(loadLayersModel)進(jìn)行預(yù)測
慕尼黑8549860
2021-05-13 14:15:24