{"action":"opened","issue":{"url":"https://api.github.com/repos/fastai/fastai/issues/848","repository_url":"https://api.github.com/repos/fastai/fastai","labels_url":"https://api.github.com/repos/fastai/fastai/issues/848/labels{/name}","comments_url":"https://api.github.com/repos/fastai/fastai/issues/848/comments","events_url":"https://api.github.com/repos/fastai/fastai/issues/848/events","html_url":"https://github.com/fastai/fastai/issues/848","id":367191823,"node_id":"MDU6SXNzdWUzNjcxOTE4MjM=","number":848,"title":"MultiBatchRNN object has no  attribute 'hidden'","user":{"login":"samuelharden","id":1573133,"node_id":"MDQ6VXNlcjE1NzMxMzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1573133?v=4","gravatar_id":"","url":"https://api.github.com/users/samuelharden","html_url":"https://github.com/samuelharden","followers_url":"https://api.github.com/users/samuelharden/followers","following_url":"https://api.github.com/users/samuelharden/following{/other_user}","gists_url":"https://api.github.com/users/samuelharden/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelharden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelharden/subscriptions","organizations_url":"https://api.github.com/users/samuelharden/orgs","repos_url":"https://api.github.com/users/samuelharden/repos","events_url":"https://api.github.com/users/samuelharden/events{/privacy}","received_events_url":"https://api.github.com/users/samuelharden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-05T12:35:25Z","updated_at":"2018-10-05T12:35:25Z","closed_at":null,"author_association":"NONE","body":"<!-- **Please note**: Installation issues should be reported here: http://forums.fast.ai/t/fastai-v1-install-issues-thread/24111 -->\r\n\r\n**Describe the bug**\r\n<!-- A clear and concise description of what the bug is. -->\r\nWhen MultiBatchRNN is used without RNNLearner . i.e externally or independently.\r\nRNNEncoder's reset function is not called and hence self.hidden variable doesn't get declared which leads to error\r\n\r\n```\r\nFile \"/scratch/gaurava/miniconda/envs/fastai/lib/python3.6/site-packages/fastai-0.7.0-py3.6.egg/fastai/lm_rnn.py\", line 137, in forward\r\n    if self.hidden:\r\n  File \"/scratch/gaurava/miniconda/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/module.py\", line 398, in __getattr__\r\n    type(self).__name__, name))\r\nAttributeError: 'MultiBatchRNN' object has no attribute 'hidden'\r\nmkdir: cannot create directory ‘../checkpoints/ag/lwf_ia/’: No such file or directory\r\n\r\n```\r\nCode in question\r\n```\r\n          for l in self.hidden:\r\n            for h in l: h.data.zero_()\r\n```\r\n\r\nSimple Fix\r\n```\r\n        if hasattr(self, 'hidden'):\r\n          for l in self.hidden:\r\n            for h in l: h.data.zero_()\r\n        else:\r\n          self.reset()\r\n\r\n```\r\n\r\n**Expected behavior**\r\nIt should declare the hidden layers during initialization.\r\nAbove simple fix solves the issue for me. But I wonder if it should be pushed during initialization.\r\n\r\n**Additional context**\r\n<!-- Add any other context about the problem here. -->\r\nI can push a PR if this solution seems right.\r\n"}}
{"actor":{"display_login":"samuelharden"}}