Loading model from json object Keras
up vote
0
down vote
favorite
My script to load Keras CNN model from saved json object is as follows:
import keras
from keras.models import model_from_json
json_file = open('k_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
model_from_json is throwing the following error :
TypeError: __init__() takes at least 4 arguments (3 given)
Has anyone faced similar issue?
Note: In Python3 it works fine, even in Python2.7 it was working fine earlier.
Complete stack trace as follows :
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 63, in <module>
loaded_model = model_from_json(loaded_model_json)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 197, in model_from_json
return layer_from_config(config, custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1019, in from_config
layer = get_or_create_layer(first_layer)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1003, in get_or_create_layer
layer = layer_from_config(layer_data)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 929, in from_config
return cls(**config)
TypeError: __init__() takes at least 4 arguments (3 given)
Failed with exit code: 1
python keras neural-network conv-neural-network data-science
add a comment |
up vote
0
down vote
favorite
My script to load Keras CNN model from saved json object is as follows:
import keras
from keras.models import model_from_json
json_file = open('k_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
model_from_json is throwing the following error :
TypeError: __init__() takes at least 4 arguments (3 given)
Has anyone faced similar issue?
Note: In Python3 it works fine, even in Python2.7 it was working fine earlier.
Complete stack trace as follows :
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 63, in <module>
loaded_model = model_from_json(loaded_model_json)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 197, in model_from_json
return layer_from_config(config, custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1019, in from_config
layer = get_or_create_layer(first_layer)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1003, in get_or_create_layer
layer = layer_from_config(layer_data)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 929, in from_config
return cls(**config)
TypeError: __init__() takes at least 4 arguments (3 given)
Failed with exit code: 1
python keras neural-network conv-neural-network data-science
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My script to load Keras CNN model from saved json object is as follows:
import keras
from keras.models import model_from_json
json_file = open('k_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
model_from_json is throwing the following error :
TypeError: __init__() takes at least 4 arguments (3 given)
Has anyone faced similar issue?
Note: In Python3 it works fine, even in Python2.7 it was working fine earlier.
Complete stack trace as follows :
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 63, in <module>
loaded_model = model_from_json(loaded_model_json)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 197, in model_from_json
return layer_from_config(config, custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1019, in from_config
layer = get_or_create_layer(first_layer)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1003, in get_or_create_layer
layer = layer_from_config(layer_data)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 929, in from_config
return cls(**config)
TypeError: __init__() takes at least 4 arguments (3 given)
Failed with exit code: 1
python keras neural-network conv-neural-network data-science
My script to load Keras CNN model from saved json object is as follows:
import keras
from keras.models import model_from_json
json_file = open('k_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
model_from_json is throwing the following error :
TypeError: __init__() takes at least 4 arguments (3 given)
Has anyone faced similar issue?
Note: In Python3 it works fine, even in Python2.7 it was working fine earlier.
Complete stack trace as follows :
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 63, in <module>
loaded_model = model_from_json(loaded_model_json)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 197, in model_from_json
return layer_from_config(config, custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1019, in from_config
layer = get_or_create_layer(first_layer)
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 1003, in get_or_create_layer
layer = layer_from_config(layer_data)
File "/usr/local/lib/python2.7/dist-packages/keras/utils/layer_utils.py", line 36, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 929, in from_config
return cls(**config)
TypeError: __init__() takes at least 4 arguments (3 given)
Failed with exit code: 1
python keras neural-network conv-neural-network data-science
python keras neural-network conv-neural-network data-science
edited Nov 19 at 7:11
asked Nov 18 at 21:07
iprof0214
7210
7210
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04
add a comment |
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365464%2floading-model-from-json-object-keras%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's very hard to know where this error is coming from. Can you put the entire stack trace?
– Daniel Möller
Nov 18 at 22:53
@DanielMöller - Edited the post with complete stack trace
– iprof0214
Nov 19 at 7:11
Hmmm, hard to tell, but it seems there is some kind of bug or version incompatibility there.
– Daniel Möller
Nov 20 at 1:04