MLWIC2 icon indicating copy to clipboard operation
MLWIC2 copied to clipboard

AttributeError: module 'tensorflow._api.v2.train' has no attribute 'slice_input_producer'

Open rasutt opened this issue 3 years ago • 2 comments

Hi there,

I am trying to test the species model on the example images. At first I got the error

Traceback (most recent call last): File "run.py", line 412, in main() File "run.py", line 351, in main sess = tf.Session(config=tf.ConfigProto( AttributeError: module 'tensorflow' has no attribute 'Session'

So I uncommented the lines

import tensorflow.compat.v1 as tf tf.disable_v2_behavior()

and now I get the error

Traceback (most recent call last): File "run.py", line 412, in main() File "run.py", line 394, in main do_evaluate(sess, args) File "run.py", line 224, in do_evaluate val_images, val_labels, val_info = val_loader.load() File "/home/robinaldridge-sutton/Code/MLWIC2/MLWIC2_helper_files/data_loader.py", line 140, in load filename_queue = tf.train.slice_input_producer([filenames, labels], shuffle= self.shuffle if self.is_training else False) AttributeError: module 'tensorflow._api.v2.train' has no attribute 'slice_input_producer'

I found a recommendation to use tf.data.Dataset.from_tensor_slices, as tf.train.slice_input_producer is apparently now deprecated.

I'm not sure if this package is still being maintained or if there might be something new in the works?

rasutt avatar Aug 25 '21 21:08 rasutt

Hi there, I was running into similar issues with TensorFlow. After researching, I found that the version of TensorFlow may be the problem. Setting up my environment in Anaconda with Python version 3.7 and Tensorflow version 1.15 fixed the issues. I still received TensorFlow errors in R when running the code, but the Classify function was able to run and produce a .csv file with the AI's suggestions for image identification. [https://github.com/dlknapps/Anaconda-Enviorment-Fix-for-MLWIC2]

dlknapps avatar Aug 02 '22 20:08 dlknapps

Hello @mikeyEcology, I received the same error rasutt described last year. Here is the output for your reference. I have r-reticulate activated, Python 3.7, and Tensorflow 1.14, but I am receiving this error. Could you please help me to resolve this?

Your data_info file exists: /Users/bradyparlato/Desktop/image_labels.csv. Your `path_prefix exists: /Users/bradyparlato/Desktop/images. You are not using a Windows computer. Traceback (most recent call last): File "/Users/bradyparlato/Desktop/MLWIC2_helper_files/run.py", line 412, in main() File "/Users/bradyparlato/Desktop/MLWIC2_helper_files/run.py", line 351, in main sess = tf.Session(config=tf.ConfigProto( AttributeError: module 'tensorflow' has no attribute 'Session' The classify function did not run properly.

bradyp97 avatar Aug 22 '22 17:08 bradyp97