简体   繁体   English

如何修复此模块'tensorflow'没有属性'lite'?

[英]How to fix this module 'tensorflow' has no attribute 'lite'?

I copied the code from https://www.tensorflow.org/lite/convert/python_api and while running the code it gives me this error module 'tensorflow' has no attribute 'lite' 我从https://www.tensorflow.org/lite/convert/python_api复制了代码,在运行代码时,它给了我这个错误模块'tensorflow'没有属性'lite'

I haven't seen any tutorials that can fix my problem, so am trying to ask here if anyone can help me with my problem 我还没有看过任何可以解决我问题的教程,所以想在这里问是否有人可以帮助我解决我的问题

This is the copied code from tensorflow lite official documentation and when I tried to run it, it gives me this error "module 'tensorflow' has no attribute 'lite'" 这是从tensorflow lite官方文档复制的代码,当我尝试运行它时,它给我这个错误``模块'tensorflow'没有属性'lite'''

import tensorflow as tf

img = tf.placeholder(name="img", dtype=tf.float32, shape=(1, 64, 64, 3))
var = tf.get_variable("weights", dtype=tf.float32, shape=(1, 64, 64, 3))
val = img + var
out = tf.identity(val, name="out")

with tf.Session() as sess:
  sess.run(tf.global_variables_initializer())
  converter = tf.lite.TFLiteConverter.from_session(sess, [img], [out])
  tflite_model = converter.convert()
  open("converted_model.tflite", "wb").write(tflite_model)

Sorry for the inconvenience, you can fix it by downloading the nightly. 很抱歉给您带来不便,您可以通过每晚下载来解决。

Edit: or using tf.contrib.lite should also work. 编辑:或使用tf.contrib.lite也应该起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM