File size: 628 Bytes
7f7a754 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #pragma once
#include "../core/tensor.hpp"
#include <vector>
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
|