pulsatrix
Loading...
Searching...
No Matches
mse_loss.hpp
Go to the documentation of this file.
1
5#pragma once
6
9
10namespace pulsatrix {
11
19class MSELoss {
20public:
25 explicit MSELoss(DeviceBackend* backend);
26
35 [[nodiscard]] float forward(const Tensor& prediction, const Tensor& target);
36
43 [[nodiscard]] Tensor backward() const;
44
45private:
46 DeviceBackend* backend_;
47 Tensor last_prediction_;
48 Tensor last_target_;
49};
50
51} // namespace pulsatrix
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
MSE = mean((prediction - target)^2).
Definition mse_loss.hpp:19
float forward(const Tensor &prediction, const Tensor &target)
Computes the loss value and caches prediction/target for backward().
Tensor backward() const
Computes the gradient w.r.t. the prediction: (2/n) * (prediction - target).
MSELoss(DeviceBackend *backend)
Constructs an MSE loss.
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
Definition acquisition_functions.hpp:16
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).