Module: TorchModel::Tensor
- Defined in:
- lib/rbbt/vector/model/torch/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.setup(obj) ⇒ Object
17 18 19 |
# File 'lib/rbbt/vector/model/torch/helpers.rb', line 17 def self.setup(obj) obj.extend Tensor end |
Instance Method Details
#del ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rbbt/vector/model/torch/helpers.rb', line 21 def del self.detach self.grad = nil self.storage.resize_ 0 self.to("cpu") end |
#length ⇒ Object
13 14 15 |
# File 'lib/rbbt/vector/model/torch/helpers.rb', line 13 def length PyCall.len(self) end |
#to_ruby ⇒ Object
3 4 5 |
# File 'lib/rbbt/vector/model/torch/helpers.rb', line 3 def to_ruby RbbtPython.numpy2ruby(self) end |
#to_ruby! ⇒ Object
7 8 9 10 11 |
# File 'lib/rbbt/vector/model/torch/helpers.rb', line 7 def to_ruby! r = self.to_ruby self.del r end |