第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

TensorFlow:使用 Tensorflow 2.2.0 將 SavedModel.pb

TensorFlow:使用 Tensorflow 2.2.0 將 SavedModel.pb

POPMUISE 2022-12-20 12:14:20
我一直在無休止地尋找一個 python 腳本或命令行函數(shù)來將 .pb 文件轉(zhuǎn)換為 .tflite。我試過使用 tflite_convert,但它返回錯誤:OSError:SavedModel 文件不存在于:C:/tensorflowTraining/export_dir/saved_model.pb/{saved_model.pbtxt|saved_model.pb}我還嘗試了一些腳本,例如:import tensorflow as togf = tf.compat.v1.GraphDef()m_file = open('saved_model.pb', 'rb')gf.ParseFromString(m_file.read())with open('somefile.txt', 'a') as the_file:    for n in gf.node:        the_file.write(n.name+'\n')file = open('somefile.txt', 'r')data = file.readlines()print("output name = ")print(data[len(data)-1])print("Input name = ")file.seek(0)print(file.readline())這將返回:發(fā)生異常:DecodeError意外的結(jié)束組標(biāo)記。這個錯誤發(fā)生在第 4 行: gf.ParseFromString(m_file.read())如果有人可以提供工作腳本或命令行功能,那將非常有幫助,正如我研究過的那樣返回錯誤或無法正常運行。謝謝!
查看完整描述

1 回答

?
溫溫醬

TA貢獻(xiàn)1752條經(jīng)驗 獲得超4個贊

你可以嘗試像下面這樣的東西TF2.2。


import tensorflow as tf 

graph_def_file = "./saved_model.pb"

tflite_file = 'mytflite.tflite'


input_arrays = ["input"]. # you need to change it based on your model

output_arrays = ["output"] # you need to change it based on your model

print("{} -> {}".format(graph_def_file, tflite_file))

converter = tf.compat.v1.lite.TFLiteConverter.from_frozen_graph(

  graph_def_file=graph_def_file,

  input_arrays=input_arrays,

  output_arrays=output_arrays,input_shapes={'input_mel':[ 1, 50, 80]})

# If there are multiple inputs, then update the dictionary above

tflite_model = converter.convert()

open(tflite_file,'wb').write(tflite_model)

在上面的代碼中,您需要使用與您的模型相對應(yīng)的input_arrays, output_arrays, 和。input_shapes


查看完整回答
反對 回復(fù) 2022-12-20
  • 1 回答
  • 0 關(guān)注
  • 264 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號