MCPcopy Create free account
hub / github.com/pytorch/tutorials / string

Method string

beginner_source/examples_nn/polynomial_module.py:37–41  ·  view source on GitHub ↗

Just like any class in Python, you can also define custom method on PyTorch modules

(self)

Source from the content-addressed store, hash-verified

35 return self.a + self.b * x + self.c * x ** 2 + self.d * x ** 3
36
37 def string(self):
38 """
39 Just like any class in Python, you can also define custom method on PyTorch modules
40 """
41 return f'y = {self.a.item()} + {self.b.item()} x + {self.c.item()} x^2 + {self.d.item()} x^3'
42
43
44# Create Tensors to hold input and outputs.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected