| namespace newnet { | |
| // Abstract base class — every layer implements these two methods | |
| class Layer { | |
| public: | |
| virtual ~Layer() = default; | |
| // Forward: takes input tensor, returns output tensor | |
| virtual Tensor forward(const Tensor& input) = 0; | |
| // Backward: takes gradient from layer above, returns gradient to pass down | |
| virtual Tensor backward(const Tensor& grad_output) = 0; | |
| // Return all learnable parameters (weights, biases) for optimizer | |
| virtual std::vector<Tensor*> parameters() { return {}; } | |
| }; | |
| } // namespace newnet | |