0

I am trying to make a basic machine learning app that allows the user to upload an image and runs it through a model. I am running into this error when I try to import my model and weights.

`json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
loaded_model.load_weights("model.h5")`

I get this error:

File "flasktesting2.py", line 17, in <module>
loaded_model = model_from_json(loaded_model_json)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/engine/saving.py", line 492, in model_from_json
return deserialize(config, custom_objects=custom_objects)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/utils/generic_utils.py", line 145, in 
deserialize_keras_object
list(custom_objects.items())))
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/engine/sequential.py", line 301, in from_config
model.add(layer)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/engine/sequential.py", line 161, in add
name=layer.name + '_input')
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/engine/input_layer.py", line 178, in Input
input_tensor=tensor)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/engine/input_layer.py", line 87, in __init__
name=self.name)
File "/Users/adityasridhar/Library/Python/2.7/lib/python/site- 
packages/keras/backend/tensorflow_backend.py", line 517, in placeholder
x = tf.placeholder(dtype, shape=shape, name=name)
AttributeError: 'module' object has no attribute 'placeholder'

I have reinstalled tensorflow and keras and ensured all my APIs are up to date. I also checked if the filenames are coinciding (ex. tensorflow.py). Does anyone know why this is happening?

Aditya S
  • 53
  • 1
  • 3
  • 7

0 Answers0