How do you calculate the training error and validation error of a linear regression model?

I have a linear regression model that I’ve implemented using Gradient Descent and my cost function is a Mean Squared Error function. I’ve split my full dataset into three datasets, a training set, a validation set, and a testing set. I am not sure how to calculate the training error and validation error (and the difference between the two).

Is the training error the Residual Sum of Squares error calculated using the training dataset? Is the validation error the Residual Sum of Squares error calculated using the validation dataset? What is the test set for exactly (I’ve learned the model using the training set, from the textbooks I’ve read I think this is the set to use to learn the model)?

Any help in clearing up these points is much appreciated.