Hello chuli,
I am also trying to use the SquaredL2Distance as the output layer of my CNN network. I tried the following attempts, however I got the mentioned errors:
       # FIRST ATTEMPT. Error got:  Tensor type mismatch, caller expects elements to be float while tensor contains double Error from operator
        dist = model.net.SquaredL2Distance([label, fc9_], 'dist')
		predictions = dist.AveragedLoss([], ['predictions'])

        # SECOND ATTEMPT: Error got: Exception: Exception when creating gradient for [Cast] ...  Argument 'from_type' of type int or string is required to get the gradient of CastOp .
		label_float = model.Cast(label, None, to=core.DataType.FLOAT)
		dist = model.net.SquaredL2Distance([label_float, fc9_], 'dist')
		predictions = dist.AveragedLoss([], ['predictions'])

Any suggestions on how to use it properly?
I created also a ticket [Caffe2] SquaredL2Distance as output layer of CNN network. Error: Exception when creating gradient for [Cast] 1 related to the L2 loss