<s> __author__ = '<STR_LIT>' <EOL> from udl . caffei . models . layers . layer import Layer , set <EOL> import udl . caffei . models . caffe_pb2 as pb2 <EOL> class LossType ( ) : <EOL> HINGE_LOSS = "<STR_LIT>" <EOL> CONTRASTIVE_LOSS = "<STR_LIT>" <EOL> EUCLIDEAN_LOSS = "<STR_LIT>" <EOL> MULTINOMIAL_LOGISTIC_LOSS = "<STR_LIT>" <EOL> SoftmaxWithLoss = "<STR_LIT>" <EOL> SOFTMAX = "<STR_LIT>" <EOL> SIGMOID_CROSS_ENTROPY_LOSS = "<STR_LIT>" <EOL> class Loss ( Layer ) : <EOL> def __init__ ( self , name , type = None , top = None , bottom = None , include = None , exclude = None , params = None ) : <EOL> super ( Loss , self ) . __init__ ( name , top , bottom , type , None , include , exclude ) <EOL> if type == LossType . HINGE_LOSS : <EOL> self . _layer . hinge_loss_param . CopyFrom ( params . str ( ) ) <EOL> self . params = params <EOL> def str ( self ) : <EOL> return self . _layer <EOL> class HingeLossParamters ( object ) : <EOL> L1 = pb2 . HingeLossParameter . L1 <EOL> L2 = pb2 . HingeLossParameter . L2 <EOL> def __init__ ( self , norm = L2 ) : <EOL> print norm <EOL> self . params = pb2 . HingeLossParameter ( ) <EOL> self . norm = norm <EOL> print self . params . norm <EOL> @ property <EOL> def norm ( self ) : <EOL> return self . params . norm <EOL> @ norm . setter <EOL> def norm ( self , val ) : <EOL> self . params . norm = set ( self . params . norm , val ) <EOL> def str ( self ) : <EOL> return self . params <EOL> class ContrastiveLossParameter ( object ) : <EOL> def __init__ ( self , margin ) : <EOL> self . params = pb2 . ContrastiveLossParameter ( ) <EOL> self . margin = margin <EOL> @ property <EOL> def margin ( self ) : <EOL> return self . params . margin <EOL> @ margin . setter <EOL> def margin ( self , val ) : <EOL> self . params . margin = set ( self . params . margin , val ) <EOL> def str ( self ) : <EOL> return self . params <EOL> class ContrastiveLossParameter ( object ) : <EOL> def __init__ ( self , margin ) : <EOL> self . params = pb2 . ContrastiveLossParameter ( ) <EOL> self . margin = margin <EOL> @ property <EOL> def margin ( self ) : <EOL> return self . params . margin <EOL> @ margin . setter <EOL> def margin ( self , val ) : <EOL> self . params . margin = set ( self . params . margin , val ) <EOL> def str ( self ) : <EOL> return self . params </s>
