-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix named_modules #10
Fix named_modules #10
Conversation
Fix undefined method `include?' for nil:NilClass in Torch::NN::Module#named_modules
Hey @nerdinand, thanks for the PR! Can you paste the stack trace of the error you're seeing? |
Without this I'm getting:
|
Is there a chance you removed the |
For some reason, when installing torch.rb with gem 'torch-rb', github: 'ankane/torch.rb' then i get
when i It also gives me these warnings while bundling, not sure if that means anything:
But yes, I guess you're right, I must have changed it locally. When installing 0.3.0 from rubygems it looks like this: # TODO return enumerator?
def named_modules(memo: nil, prefix: "")
ret = {}
memo ||= Set.new
unless memo.include?(self)
memo << self
ret[prefix] = self
named_children.each do |name, mod|
next unless mod.is_a?(Module)
submodule_prefix = prefix + (!prefix.empty? ? "." : "") + name
mod.named_modules(memo: memo, prefix: submodule_prefix).each do |m|
ret[m[0]] = m[1]
end
end
end
ret
end (of course with the bug from #9 again) |
I'm not able to reproduce the require "bundler/setup"
require "torch" The Bundler warnings aren't anything to worry about (not specific to Torch.rb). |
Hmm, very interesting, that indeed in this case i need require 'bundler/setup' for it to work... Or indeed running with |
Glad that fixed it. The reason is Ruby doesn't know how to find gems installed by Bundler from GitHub without Bundler (if that makes any sense). |
Fix undefined method `include?' for nil:NilClass in Torch::NN::Module#named_modules