新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
TensorFlow實(shí)現(xiàn)保存訓(xùn)練模型為pd文件并恢復(fù)-創(chuàng)新互聯(lián)
TensorFlow保存模型代碼
import tensorflow as tf from tensorflow.python.framework import graph_util var1 = tf.Variable(1.0, dtype=tf.float32, name='v1') var2 = tf.Variable(2.0, dtype=tf.float32, name='v2') var3 = tf.Variable(2.0, dtype=tf.float32, name='v3') x = tf.placeholder(dtype=tf.float32, shape=None, name='x') x2 = tf.placeholder(dtype=tf.float32, shape=None, name='x2') addop = tf.add(x, x2, name='add') addop2 = tf.add(var1, var2, name='add2') addop3 = tf.add(var3, var2, name='add3') initop = tf.global_variables_initializer() model_path = './Test/model.pb' with tf.Session() as sess: sess.run(initop) print(sess.run(addop, feed_dict={x: 12, x2: 23})) output_graph_def = graph_util.convert_variables_to_constants(sess, sess.graph_def, ['add', 'add2', 'add3']) # 將計算圖寫入到模型文件中 model_f = tf.gfile.FastGFile(model_path, mode="wb") model_f.write(output_graph_def.SerializeToString())
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
新聞名稱:TensorFlow實(shí)現(xiàn)保存訓(xùn)練模型為pd文件并恢復(fù)-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://fisionsoft.com.cn/article/ccppcs.html