import numpy as np

class MeanSquaredError():

    def forward(self, y, t):
        self.y = y
        self.t = t
        return np.mean((y - t) ** 2)

    def backward(self, y, t):
        n = y.shape[0]
        return (2 / n) * (y - t)