5

When I try to run the code in machinelearningmastery , I get

AttributeError: module 'tensorflow' has no attribute 'random_shuffle'

And it points at the following

from mrcnn.model import MaskRCNN
from mrcnn.config import Config

model = MaskRCNN(mode='training', model_dir='./', config=config)

How can one solve this ?

2

3 Answers 3

13

It's likely you have Tensorflow 2.0 installed and the code on machine learning mastery has been written on top of tf < 2.0.

You can do either of two things:

  • Downgrade your tf to v1.x
  • Change tf.random_shuffle to tf.random.shuffle

Also, consider downgrading Keras from v2.3.1 to v2.1.1 (not a must though)

1

TensorFlow 2.0 has a different API than TensorFlow 1.x, you cannot run software that is made for TensorFlow 1.3 in version 2.0, you need to either downgrade TensorFlow, or find a version of the software that is explicitly made compatible with TensorFlow 2.x

1

I have the same issue. And it is resolved by changing tf.random_shuffle to tf.random.shuffle

2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.