Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in running Demo.py #17

Open
bardia-esm opened this issue Nov 15, 2018 · 9 comments
Open

error in running Demo.py #17

bardia-esm opened this issue Nov 15, 2018 · 9 comments

Comments

@bardia-esm
Copy link

bardia-esm commented Nov 15, 2018

Hi,
when I try to run Demo.py I get an error in line of model_from_json(open('model.json').read())
the error is as bellow:
Exception has occurred: ValueError
Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}
File "/home/bardia/Desktop/Untitled-1.py", line 3, in
model = model_from_json(open(json_path).read())

the error is in model.json file in line of W_regularizer:

W_regularizer": {"l2": 0.0010000000474974513, "name": "WeightRegularizer", "l1": 0.0}

I search the error and it looks like that for version 2.2 Keras I have to use custome_object paramter inside model_from_json(open('model.json').read()) .

So In a new file, I changed the code to:

from keras.models import model_from_json
model = model_from_json(open('model.json').read(), custom_objects={'WeightRegularizer':W_regularizer}

However, I get the following error:
Exception has occurred: NameError
name 'W_regularizer' is not defined

I would really appreciate it if you share a solution
thanks a lot

@WaqasSultani
Copy link
Owner

I think you have different keras ( and backend theano version) compared to what I used in experiments

@bardia-esm
Copy link
Author

Hello @WaqasSultani thanks for your great work, so I guess I have to use the older version of keras

@Singapore-mor
Copy link

Hello @WaqasSultani thanks for your great work, so I guess I have to use the older version of keras

Hi BaRdia-eSm i ,
when I try to run Demo.py, i confronted the same problem
Exception has occurred: ValueError
I tried to use the older version of keras, keras 1.10
but it occurs
AttributeError: module 'tensorflow' has no attribute 'python'
I don't know what happened

@libb999
Copy link

libb999 commented Dec 17, 2019

Hello @WaqasSultani thanks for your great work, so I guess I have to use the older version of keras

Hi BaRdia-eSm i ,
when I try to run Demo.py, i confronted the same problem
Exception has occurred: ValueError
I tried to use the older version of keras, keras 1.10
but it occurs
AttributeError: module 'tensorflow' has no attribute 'python'
I don't know what happened

Hi,I meet the same problem: AttributeError: module 'tensorflow' has no attribute 'python'
can you tell me how to solve it?
thank you very much

@iShahad97
Copy link

@libb999 & @Singapore-mor, you have to change the backend from tensorflow to theano, there are two ways:

  1. Configure the file "$ HOME / .keras / keras.json" and set "theano" as back-end:

{
"image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}
2. Use this code:
def set_keras_backend(backend):

if K.backend() != backend:
os.environ['KERAS_BACKEND'] = backend
importlib.reload(K)
assert K.backend() == backend

set_keras_backend("theano")

@sahilsingh31
Copy link

File "/home/sahilsingh/.local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 129, in deserialize_keras_object
raise ValueError('Improper config format: ' + str(config))

ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}

how to solve this error, i tried for various solutions over internet but didn't got one

@sanjayroka05
Copy link

File "/home/sahilsingh/.local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 129, in deserialize_keras_object
raise ValueError('Improper config format: ' + str(config))

ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}

how to solve this error, i tried for various solutions over internet but didn't got one

I'm also having the same errror...

ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}

@Angel3636
Copy link

File "/home/sahilsingh/.local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 129, in deserialize_keras_object
raise ValueError('Improper config format: ' + str(config))
ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}
how to solve this error, i tried for various solutions over internet but didn't got one

I'm also having the same errror...

ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}

Hello, is anyone got the solution for this?

@jiafeixiaoye
Copy link

File "/home/sahilsingh/.local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 129, in deserialize_keras_object
raise ValueError('Improper config format: ' + str(config))

ValueError: Improper config format: {'l2': 0.0010000000474974513, 'name': 'WeightRegularizer', 'l1': 0.0}

how to solve this error, i tried for various solutions over internet but didn't got one

It seems the official model is written by Keras1 and you installed Keras2. You can modify the model file with Keras2 format.
Here I replace "W_regularizer": {"l2": 0.0010000000474974513, "name": "WeightRegularizer", "l1": 0.0}
with "kernel_regularizer": {"class_name": "L1L2", "config": {"l2": 0.0010000000474974513, "l1": 0.0}}
and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants