pyanomaly/datatools/evaluate/utils.py
def reconstruction_loss(x_hat, x):
    '''
    The input is the video clip, and we use the RL as the score.
    RL := Reconstruction Loss
    '''
    x_hat = x_hat.squeeze(0).detach()
    x = x.squeeze(0).detach()
    rl = torch.sqrt(torch.pow((x_hat - x), 2))
    h_dim = len(rl.shape) - 2
    w_dim = len(rl.shape) - 1
    # the number of rl is equal to the frame number
    rl = torch.mean(rl, (h_dim, w_dim)).squeeze(0)
    if len(rl.shape) == 2:
        rl = rl.mean(0)
    elif len(rl.shape) == 1:
        rl = rl
    else:
        raise Exception('in reconstruction_loss')
    # import ipdb; ipdb.set_trace()
    return rl

    The input is the video clip, and we use the RL as the score.
    RL := Reconstruction Loss
    
The input is the video clip, and we use the RL as the score.
RL := Reconstruction Loss
The input is the video clip and we use the RL as the score . RL : = Reconstruction Loss
def reconstruction_loss(x_hat, x):
    x_hat = x_hat.squeeze(0).detach()
    x = x.squeeze(0).detach()
    rl = torch.sqrt(torch.pow((x_hat - x), 2))
    h_dim = len(rl.shape) - 2
    w_dim = len(rl.shape) - 1
    rl = torch.mean(rl, (h_dim, w_dim)).squeeze(0)
    if len(rl.shape) == 2:
        rl = rl.mean(0)
    elif len(rl.shape) == 1:
        rl = rl
    else:
        raise Exception('in reconstruction_loss')
    return rl
def reconstruction_loss ( x_hat , x ) : x_hat = x_hat . squeeze ( 0 ) . detach ( ) x = x . squeeze ( 0 ) . detach ( ) rl = torch . sqrt ( torch . pow ( ( x_hat - x ) , 2 ) ) h_dim = len ( rl . shape ) - 2 w_dim = len ( rl . shape ) - 1 rl = torch . mean ( rl , ( h_dim , w_dim ) ) . squeeze ( 0 ) if len ( rl . shape ) == 2 : rl = rl . mean ( 0 ) elif len ( rl . shape ) == 1 : rl = rl else : raise Exception ( 'in reconstruction_loss' ) return rl
The input is the video clip, and we use the RL as the score.
The input is the video clip and we use the RL as the score .
'''
    The input is the video clip, and we use the RL as the score.
    RL := Reconstruction Loss
    ''' # the number of rl is equal to the frame number
 # import ipdb; ipdb.set_trace()

x_hat
x