简体   繁体   中英

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'

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'"

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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