Do I need to rescale input labels before training (label values between 20..51)?

I'm trying to build model for this datatset (Age prediction):

  • The input image has the shape: 3, 128, 128 and the predicted labels (ages) range between 20 to 51.

I want to build model and train it with MSE and R2 metrics.

I built the following model:

def GetPretrainedModel():
    oModel = torchvision.models.resnet50(pretrained=True)
    
    for mParam in oModel.parameters():
        if False == isinstance(mParam, nn.BatchNorm2d):
            mParam.requires_grad = False
        
    
    dIn       = oModel.fc.in_features
    oModel.fc = nn.Sequential(
        nn.Linear(dIn, 512), nn.ReLU(),
        nn.Linear(512, 256), nn.ReLU(),
        nn.Linear(256, 128), nn.ReLU(),       
        nn.Linear(128, 1)
    )
    
    return oModel
  • In order to train the model, Is it worth updating the input true age values to values between 0 to 30 or between 0 to 1 ?
  • Is there a recommendation to add another layer to the model which will change the output values to the range between [20..50] ?

Topic mse r-squared deep-learning

Category Data Science


It is not necessary to scale the "age" label as your last linear neuron (in the last layer) is also learning a bias (b) parameter.

enter image description here

Concerning your last point, it could make sense to force your prediction to lay in range [20, 50] if and only if you are sure that all your future observations would also be in the range [20, 50] (which is pretty rare in practice, take a look on data drift and concept drift notions).

If you are sure there will ne drift in your future observations, your idea makes sense. And the best thing to do will be not to add a last layer, but to add a post-processing function to force your prediction to be in that range.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.