in c3dm/c3dpo.py [0:0]
def __init__( self, n_keypoints = 17,
shape_basis_size = 10,
mult_shape_by_class_mask = False,
squared_reprojection_loss = False,
n_fully_connected = 1024,
n_layers = 6,
keypoint_rescale = float(1),
keypoint_norm_type = 'to_mean',
projection_type = 'orthographic',
z_augment = True,
z_augment_rot_angle = float(np.pi),
z_equivariance = False,
z_equivariance_rot_angle = float(np.pi)/4, # < 0 means same as z_augment_rot_angle
compose_z_equivariant_rot = True, # TODO: remove this soon!
camera_translation = False,
camera_xy_translation = True,
argmin_translation = False,
argmin_translation_test = False,
argmin_translation_min_depth = 3.,
argmin_to_augmented = False,
camera_scale = False,
argmin_scale = False,
argmin_scale_test = False,
loss_normalization = 'kp_total_count',
independent_phi_for_aug = False,
shape_pred_wd = 1.,
connectivity_setup = 'NONE',
custom_param_groups = False,
use_huber = False,
huber_scaling = 0.1,
alpha_bias = True,
canonicalization = {
'use': False,
'n_layers': 6,
'n_rand_samples': 4,
'rot_angle': float(np.pi),
'n_fully_connected': 1024,
},
linear_instead_of_conv = False,
perspective_depth_threshold = 0.1,
depth_offset = 0.,
replace_keypoints_with_input = False,
root_joint = 0,
loss_weights = { 'l_reprojection': 1.,
'l_canonicalization': 1. },
log_vars = [ \
'objective',
'dist_reprojection',
'l_reprojection',
'l_canonicalization' ],
**kwargs ):
super(C3DPO, self).__init__()
# autoassign constructor params to self
auto_init_args(self)
# factorization net
self.phi = nn.Sequential( \
*make_trunk( dim_in=self.n_keypoints * 3 , # 2 dim loc, 1 dim visibility
n_fully_connected=self.n_fully_connected,
n_layers=self.n_layers ) )
if linear_instead_of_conv:
layer_init_fn = linear_layer
else:
layer_init_fn = conv1x1
# shape coefficient predictor
self.alpha_layer = layer_init_fn( self.n_fully_connected,
self.shape_basis_size,
init='normal0.01',
cnv_args = {'bias': self.alpha_bias,
'kernel_size': 1 } )
# 3D shape predictor
self.shape_layer = layer_init_fn( self.shape_basis_size,
3*n_keypoints,
init='normal0.01' )
# rotation predictor (predicts log-rotation)
self.rot_layer = layer_init_fn(self.n_fully_connected,3,init='normal0.01')
if self.camera_translation:
# camera translation
self.translation_layer = layer_init_fn(self.n_fully_connected,3,init='normal0.01')
if self.camera_scale:
# camera scale (non-negative predictions)
self.scale_layer = nn.Sequential( \
layer_init_fn(self.n_fully_connected,1,init='normal0.01'),
nn.Softplus() )
if self.canonicalization['use']:
# canonicalization net:
self.psi = nn.Sequential( \
*make_trunk( dim_in=self.n_keypoints*3 ,
n_fully_connected=self.canonicalization['n_fully_connected'],
n_layers=self.canonicalization['n_layers'] ) )
self.alpha_layer_psi = conv1x1( \
self.n_fully_connected,
self.shape_basis_size,
init='normal0.01')