ConverterError:TOCO失败。请参阅控制台以获取信息

时间:2019-03-19 13:32:52

标签: python tensorflow toco

我是Tensor流的新手,我正在运行我的第一个张量流示例,但发现了这个问题。 我该怎么办

“ TOCO失败。有关信息,请参见控制台。\ n%s \ n%s \ n”%(stdout,stderr))

ConverterError: TOCO failed. See console for info.
Traceback (most recent call last):`enter code here`
  File "D:\Software\Scripts\toco_from_protos-script.py", line 6, in <module>
    from tensorflow.lite.toco.python.toco_from_protos import main
  File "D:\Software\lib\site-packages\tensorflow\__init__.py", line 31, in <module>
    from tensorflow._api.v1 import audio
ImportError: cannot import name 'audio' from 'tensorflow._api.v1' (D:\Software\lib\site-packages\tensorflow\_api\v1\__init__.py)

下面是我的python代码

import tensorflow as tf    
import numpy as np    
from tensorflow import keras    
from tensorflow import lite    

model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])])    
model.compile(optimizer='sgd',loss='mean_squared_error');    

xs=np.array([-1.0,0.0,1.0,2.0,3.0,4.0], dtype=float)    
ys= np.array([-3.0,-1.0,0.0,3.0,5.0,7.0],dtype=float)    

model.fit(xs,ys,epochs=20)    

print(model.predict([6.0]))    

#write out the keras save file    
keras_file="linear.h5"    
keras.models.save_model(model,keras_file)    

#convert to tensor flow     
converter = lite.TocoConverter.from_keras_model_file(keras_file)      
tflite_model = converter.convert()    

open('linear.tflite','wb').write(tflite_model)    

0 个答案:

没有答案