3 ms·
I feel the biggest weakness of PyTorch is that everything is an object with inheritance. It makes no sense that ReLu is a class for example. Seems like ML cou
by nightski 3y ago
I feel the biggest weakness of PyTorch is that everything is an object with inheritance. It makes no sense that ReLu is a class for example. Seems like ML could take a few hints.
- vore 3y agoWell, PyTorch uses classes more as a declarative way to construct your neural networks. It doesn’t get more data-oriented than pushing thousands of tensors through your GPU!
- hexane360 3y agoDeclarative vs. procedural is orthogonal to data oriented vs. object oriented. The functional way to make a declarative interface would be to have a single type, `Expression`, and all operators take expressions and return expressions. However, I would argue the declarative vs. procedural decision is much more important to the resulting code structure then whether you use a single object type or multiple object types with inheritance.
- gloryjulio 3y agoThe problem is that with python oop, the class is ur type. Therefore it comes with all the oop baggages. If u squint enough and avoid those baggages and only leverage the type system(hint), then it's kinda usable. U don't have much choices anyway.
- vore 3y agoIt's complicated because PyTorch also uses class syntax to allow you to introspect the various blocks in your modules. It's a bit of a kludge, but composing it strictly out of Expressions would remove that introspection capability.
- jebarker 3y agoI agree that often people choose to use the object versions unnecessary, but many operations (including relu) have functional versions: https://pytorch.org/docs/stable/generated/torch.nn.functional.relu.html https://pytorch.org/docs/stable/generated/torch.nn.functiona...