{"action":"closed","issue":{"url":"https://api.github.com/repos/aigamedev/scikit-neuralnetwork/issues/188","repository_url":"https://api.github.com/repos/aigamedev/scikit-neuralnetwork","labels_url":"https://api.github.com/repos/aigamedev/scikit-neuralnetwork/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/aigamedev/scikit-neuralnetwork/issues/188/comments","events_url":"https://api.github.com/repos/aigamedev/scikit-neuralnetwork/issues/188/events","html_url":"https://github.com/aigamedev/scikit-neuralnetwork/issues/188","id":138330337,"number":188,"title":"Use example for initializing pre-trained network with weights parameter","user":{"login":"etch32","id":4250224,"avatar_url":"https://avatars.githubusercontent.com/u/4250224?v=3","gravatar_id":"","url":"https://api.github.com/users/etch32","html_url":"https://github.com/etch32","followers_url":"https://api.github.com/users/etch32/followers","following_url":"https://api.github.com/users/etch32/following{/other_user}","gists_url":"https://api.github.com/users/etch32/gists{/gist_id}","starred_url":"https://api.github.com/users/etch32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etch32/subscriptions","organizations_url":"https://api.github.com/users/etch32/orgs","repos_url":"https://api.github.com/users/etch32/repos","events_url":"https://api.github.com/users/etch32/events{/privacy}","received_events_url":"https://api.github.com/users/etch32/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-03T23:33:55Z","updated_at":"2016-04-02T13:53:14Z","closed_at":"2016-04-02T13:53:14Z","body":"From the docs:\r\nweights: list of tuple of array-like, optional\r\n\r\nA list of (weights, biases) tuples to be reloaded for each layer, in the same order as layers was specified. Useful for initializing with pre-trained networks.\r\n\r\nI trained a network, e.g.\r\n\r\n```python\r\nmodel = Classifier(\r\n    layers=[\r\n        Layer(\"Sigmoid\", units=4),\r\n        Layer(\"Softmax\")],\r\n    learning_rate=0.01,\r\n    n_iter=25,\r\n    random_state=1,\r\n    verbose=False)\r\n\r\nmodel.fit(X_train, y_train)\r\n\r\n# save the weights\r\n\r\nps = model.get_parameters()\r\nweights = [(ps[0].weights, ps[0].biases), (ps[1].weights, ps[1].biases)]\r\n```\r\nWant to reinitialize model with these weights (e.g. in a new session)\r\n```python\r\nmodel2 = Classifier(\r\n    layers=[\r\n        Layer(\"Sigmoid\", units=4),\r\n        Layer(\"Softmax\")],\r\n    learning_rate=0.01,\r\n    n_iter=25,\r\n    random_state=1,\r\n    weights=weights,    # initialize with previously trained weights\r\n    verbose=False)\r\n```\r\n Then felt I should just be able to call predict\r\n```python\r\ny_pred = model2.predict(X_test)\r\n```\r\nBut get the following error.\r\n   \"Can't predict without fitting: output classes are unknown.\"\r\nAssertionError: Can't predict without fitting: output classes are unknown.\r\n\r\nOK, the part about the output classes are unknown seems reasonable. However if I call fit() then it will just re-compute the weights and use these new weights.\r\n\r\nI may be misinterpreting the intent/use of the weights parameter. \r\n\r\n\r\n"}}