{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/868","labels_url":"https://api.github.com/repos/fchollet/keras/issues/868/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/868/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/868/events","html_url":"https://github.com/fchollet/keras/issues/868","id":112669236,"number":868,"title":"Using custom loss function with model_from_json","user":{"login":"jpeg729","id":3158606,"avatar_url":"https://avatars.githubusercontent.com/u/3158606?v=3","gravatar_id":"","url":"https://api.github.com/users/jpeg729","html_url":"https://github.com/jpeg729","followers_url":"https://api.github.com/users/jpeg729/followers","following_url":"https://api.github.com/users/jpeg729/following{/other_user}","gists_url":"https://api.github.com/users/jpeg729/gists{/gist_id}","starred_url":"https://api.github.com/users/jpeg729/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpeg729/subscriptions","organizations_url":"https://api.github.com/users/jpeg729/orgs","repos_url":"https://api.github.com/users/jpeg729/repos","events_url":"https://api.github.com/users/jpeg729/events{/privacy}","received_events_url":"https://api.github.com/users/jpeg729/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-21T20:09:41Z","updated_at":"2015-10-22T01:23:54Z","closed_at":null,"body":"It doesn't work.\r\n```\r\nTraceback (most recent call last):\r\n  File \"myFile.py\", line 100, in <module>\r\n    model = model_from_json(open('savefile.json').read())\r\n  File \"build/bdist.linux-x86_64/egg/keras/models.py\", line 116, in model_from_json\r\n  File \"build/bdist.linux-x86_64/egg/keras/models.py\", line 142, in model_from_config\r\n  File \"build/bdist.linux-x86_64/egg/keras/models.py\", line 346, in compile\r\n  File \"build/bdist.linux-x86_64/egg/keras/objectives.py\", line 64, in get\r\n  File \"build/bdist.linux-x86_64/egg/keras/utils/generic_utils.py\", line 12, in get_from_module\r\nException: Invalid objective: custom_loss_function\r\n```\r\n\r\nIt is obviously trying to load the loss function from the relevant keras module, and not finding it.\r\n\r\nHow about adding some parameters to model.model_from_json? Something like `model.model_from_json(\"savefile.json\", loss=my_custom_loss_function)` would be great.\r\n\r\nMore generally though, maybe we should add the possibility of giving a dictionary of named functions for all the custom functions the model might use: activation, loss, optimizer, ..."},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/150070848","html_url":"https://github.com/fchollet/keras/issues/868#issuecomment-150070848","issue_url":"https://api.github.com/repos/fchollet/keras/issues/868","id":150070848,"user":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T01:23:53Z","updated_at":"2015-10-22T01:23:53Z","body":"> More generally though, maybe we should add the possibility of giving a dictionary of named functions for all the custom functions the model might use: activation, loss, optimizer, ...\r\n\r\nYes, that's a pertinent idea. We already have such support for custom layers. Let's see if we can extend it the custom loss functions and optimizers in the simplest possible way. Is this something you would like to take on?"}}