{"action":"opened","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/1215","labels_url":"https://api.github.com/repos/fchollet/keras/issues/1215/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/1215/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/1215/events","html_url":"https://github.com/fchollet/keras/issues/1215","id":121052621,"number":1215,"title":"Graph model with a shared node is not json-serializable","user":{"login":"hr0nix","id":4273011,"avatar_url":"https://avatars.githubusercontent.com/u/4273011?v=3","gravatar_id":"","url":"https://api.github.com/users/hr0nix","html_url":"https://github.com/hr0nix","followers_url":"https://api.github.com/users/hr0nix/followers","following_url":"https://api.github.com/users/hr0nix/following{/other_user}","gists_url":"https://api.github.com/users/hr0nix/gists{/gist_id}","starred_url":"https://api.github.com/users/hr0nix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hr0nix/subscriptions","organizations_url":"https://api.github.com/users/hr0nix/orgs","repos_url":"https://api.github.com/users/hr0nix/repos","events_url":"https://api.github.com/users/hr0nix/events{/privacy}","received_events_url":"https://api.github.com/users/hr0nix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-08T17:05:26Z","updated_at":"2015-12-08T17:05:26Z","closed_at":null,"body":"When calling graph.to_json() on a model with a siamese layer created via a call to add_shared_node, I get the following error:\r\n\r\n```\r\nTypeError: <keras.layers.core.Siamese object at 0xf1cab10> is not JSON serializable\r\n```\r\n\r\nThe results of graph.get_config() look as follows:\r\n```\r\n{   'input_config': [   {   'dtype': 'int32',\r\n                            'input_shape': (1000,),\r\n                            'name': 'encoder_input'},\r\n                        {   'dtype': 'int32',\r\n                            'input_shape': (1000,),\r\n                            'name': 'decoder_input'}],\r\n    'input_order': ['encoder_input', 'decoder_input'],\r\n    'loss': {   'decoder_output': 'categorical_crossentropy'},\r\n    'name': 'Graph',\r\n    'node_config': [   {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'inputs': ['encoder_input', 'decoder_input'],\r\n                           'merge_mode': None,\r\n                           'name': 'embedding'},\r\n                       {   'create_output': False,\r\n                           'inputs': [   <keras.layers.core.Siamese object at 0xf1cab10>],\r\n                           'name': 'embeddings_encoder'},\r\n                       {   'create_output': False,\r\n                           'inputs': [   <keras.layers.core.Siamese object at 0xf1cab10>],\r\n                           'name': 'embeddings_decoder'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': 'embeddings_encoder',\r\n                           'inputs': [],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'encoder_lstm'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': 'encoder_lstm',\r\n                           'inputs': [],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'encoder_output'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': 'encoder_output',\r\n                           'inputs': [],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'encoder_output_repeated'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': None,\r\n                           'inputs': [   'encoder_output_repeated',\r\n                                         'embeddings_decoder'],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'decoder_lstm'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': 'decoder_lstm',\r\n                           'inputs': [],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'decoder_dense'},\r\n                       {   'concat_axis': -1,\r\n                           'create_output': False,\r\n                           'dot_axes': -1,\r\n                           'input': 'decoder_dense',\r\n                           'inputs': [],\r\n                           'merge_mode': 'concat',\r\n                           'name': 'decoder_prob_est'}],\r\n    'nodes': {   'decoder_dense': {   'W_constraint': None,\r\n                                      'W_regularizer': None,\r\n                                      'activation': 'tanh',\r\n                                      'activity_regularizer': None,\r\n                                      'b_constraint': None,\r\n                                      'b_regularizer': None,\r\n                                      'init': 'glorot_uniform',\r\n                                      'input_dim': None,\r\n                                      'input_length': None,\r\n                                      'name': 'TimeDistributedDense',\r\n                                      'output_dim': 512},\r\n                 'decoder_lstm': {   'activation': 'tanh',\r\n                                     'forget_bias_init': 'one',\r\n                                     'go_backwards': False,\r\n                                     'init': 'glorot_uniform',\r\n                                     'inner_activation': 'hard_sigmoid',\r\n                                     'inner_init': 'orthogonal',\r\n                                     'input_dim': 428,\r\n                                     'input_length': None,\r\n                                     'name': 'LSTM',\r\n                                     'output_dim': 512,\r\n                                     'return_sequences': True,\r\n                                     'stateful': False},\r\n                 'decoder_prob_est': {   'W_constraint': None,\r\n                                         'W_regularizer': None,\r\n                                         'activation': 'fast_softmax',\r\n                                         'activity_regularizer': None,\r\n                                         'b_constraint': None,\r\n                                         'b_regularizer': None,\r\n                                         'init': 'glorot_uniform',\r\n                                         'input_dim': None,\r\n                                         'input_length': None,\r\n                                         'name': 'TimeDistributedDense',\r\n                                         'output_dim': 5000},\r\n                 'embedding': {   'concat_axis': -1,\r\n                                  'dot_axes': -1,\r\n                                  'inputs': [   {   'input_shape': (1000,),\r\n                                                    'name': 'Layer'},\r\n                                                {   'input_shape': (1000,),\r\n                                                    'name': 'Layer'}],\r\n                                  'layer': <bound method Embedding.get_config of <keras.layers.embeddings.Embedding object at 0x6745050>>,\r\n                                  'merge_mode': None,\r\n                                  'name': 'Siamese'},\r\n                 'embeddings_decoder': {   'head': 1, 'name': 'SiameseHead'},\r\n                 'embeddings_encoder': {   'head': 0, 'name': 'SiameseHead'},\r\n                 'encoder_lstm': {   'activation': 'tanh',\r\n                                     'forget_bias_init': 'one',\r\n                                     'go_backwards': False,\r\n                                     'init': 'glorot_uniform',\r\n                                     'inner_activation': 'hard_sigmoid',\r\n                                     'inner_init': 'orthogonal',\r\n                                     'input_dim': 300,\r\n                                     'input_length': None,\r\n                                     'name': 'LSTM',\r\n                                     'output_dim': 512,\r\n                                     'return_sequences': False,\r\n                                     'stateful': False},\r\n                 'encoder_output': {   'W_constraint': None,\r\n                                       'W_regularizer': None,\r\n                                       'activation': 'tanh',\r\n                                       'activity_regularizer': None,\r\n                                       'b_constraint': None,\r\n                                       'b_regularizer': None,\r\n                                       'init': 'glorot_uniform',\r\n                                       'input_dim': None,\r\n                                       'name': 'Dense',\r\n                                       'output_dim': 128},\r\n                 'encoder_output_repeated': {   'n': 1000,\r\n                     'lr': 0.0010000000474974513,\r\n                     'name': 'Adam'},\r\n    'output_config': [   {   'concat_axis': -1,\r\n                             'dot_axes': -1,\r\n                             'input': 'decoder_prob_est',\r\n                             'inputs': [],\r\n                             'merge_mode': 'concat',\r\n                             'name': 'decoder_output'}],\r\n    'output_order': ['decoder_output'],\r\n    'theano_mode': None}\r\n```"}}