def __init__(self, code=1024, sample_dim=2, batch_norm=True, activ_fns='relu', use_tanh=True, gpu=True, **kwargs): nn.Module.__init__(self) Device.__init__(self, gpu=gpu) DecoderCounter.__init__(self) self._code = code # Store histograms of outputs of each activation layer. self._act_hist = False if 'act_hist' in kwargs and kwargs['act_hist']: self._act_hist = True self._writer = kwargs['writer'] self._act_hist_period = kwargs['act_hist_period'] # Conv layers. code = code + sample_dim # CW is concated with `sample_dim`-D samples. self.conv1 = torch.nn.Conv1d(code, code, 1) self.conv2 = torch.nn.Conv1d(code, code // 2, 1) self.conv3 = torch.nn.Conv1d(code // 2, code // 4, 1) self.conv4 = torch.nn.Conv1d(code // 4, 3, 1) # Batch norm layers. self.bn1, self.bn2, self.bn3 = [None] * 3 if batch_norm: self.bn1 = torch.nn.BatchNorm1d(code) self.bn2 = torch.nn.BatchNorm1d(code // 2) self.bn3 = torch.nn.BatchNorm1d(code // 4) # Activation functions. self.act_func_all = self.activation_functions[activ_fns]() self.act_func_last = nn.Tanh() if use_tanh else identity # Send to device. self = self.to(self.device)
def __init__(self, code, normalize_cw=False, gpu=True): nn.Module.__init__(self) Device.__init__(self, gpu=gpu) self._normalize_cw = normalize_cw self.layers = nn.Sequential( PointNetfeat(global_feat=True, trans=False), nn.Linear(1024, code), nn.BatchNorm1d(code), nn.ReLU()) self = self.to(self.device)
def __init__(self, normals=True, curv_mean=True, curv_gauss=True, fff=False, gpu=True): nn.Module.__init__(self) Device.__init__(self, gpu=gpu) self._comp_normals = normals self._comp_cmean = curv_mean self._comp_cgauss = curv_gauss self._comp_fff = fff
def __init__(self, fff=False, alpha_chd=1., gpu=True): FoldingNetBase.__init__(self) Device.__init__(self, gpu=gpu) self._reg_func_impl = self.register_dist_based # Diff. geom. props object. self.dgp = DiffGeomProps( normals=True, curv_mean=False, curv_gauss=False, fff=fff) # These quantities have to be computed in forward() pass. self.pc_pred = None self.geom_props = None # Loss weighting coeffs. self._alpha_chd = alpha_chd
def __init__(self, M=2500, code=1024, num_patches=1, normalize_cw=False, freeze_encoder=False, enc_load_weights=None, dec_activ_fns='relu', dec_use_tanh=True, dec_batch_norm=True, loss_scaled_isometry=False, alpha_scaled_isometry=0., alphas_sciso=None, gpu=True, **kwargs): MultipatchDecoder.__init__(self, M, num_patches, loss_scaled_isometry=loss_scaled_isometry, alpha_scaled_isometry=alpha_scaled_isometry, alphas_sciso=alphas_sciso, gpu=gpu) Device.__init__(self, gpu) self._code = code self.enc = ANEncoderPN(code, normalize_cw=normalize_cw, gpu=gpu) self.sampler = FNSamplerRandUniform((0., 1.), (0., 1.), M, gpu=gpu) self.dec = DecoderMultiPatch(num_patches, DecoderAtlasNet, code=code, sample_dim=2, batch_norm=dec_batch_norm, activ_fns=dec_activ_fns, use_tanh=dec_use_tanh, gpu=gpu, **kwargs) # Load encoder weights. if enc_load_weights is not None: self.load_state_dict(torch.load(enc_load_weights), strict=False) print('[INFO] Loaded weights for PointNet encoder from {}'.format( enc_load_weights)) # Freeze encoder. if freeze_encoder: self._freeze_encoder(freeze=True)
def __init__(self, gpu=True): nn.Module.__init__(self) Device.__init__(self, gpu=gpu) # self.num_points = num_points self.conv1 = torch.nn.Conv1d(3, 64, 1) self.conv2 = torch.nn.Conv1d(64, 128, 1) self.conv3 = torch.nn.Conv1d(128, 1024, 1) self.fc1 = nn.Linear(1024, 512) self.fc2 = nn.Linear(512, 256) self.fc3 = nn.Linear(256, 9) self.relu = nn.ReLU() self._iden = torch.from_numpy(np.eye(3, dtype=np.float32)).\ reshape((1, 9)).to(self.device) self = self.to(self.device)
def __init__(self, global_feat=True, trans=False, gpu=True): nn.Module.__init__(self) Device.__init__(self, gpu=gpu) super(PointNetfeat, self).__init__() self.stn = STN3d(gpu=gpu) self.conv1 = torch.nn.Conv1d(3, 64, 1) self.conv2 = torch.nn.Conv1d(64, 128, 1) self.conv3 = torch.nn.Conv1d(128, 1024, 1) self.bn1 = torch.nn.BatchNorm1d(64) self.bn2 = torch.nn.BatchNorm1d(128) self.bn3 = torch.nn.BatchNorm1d(1024) self.trans = trans # self.num_points = num_points self.global_feat = global_feat self = self.to(self.device)
def __init__(self, M=2500, code=1024, num_patches=1, normalize_cw=False, freeze_encoder=False, enc_load_weights=None, dec_activ_fns='relu', dec_use_tanh=True, dec_batch_norm=True, loss_scaled_isometry = False, loss_smooth_surfaces = False, # zhantao loss_patch_stitching = False, # zhantao loss_patch_areas = False, # zhantao numNeighborGlobal = 20, # zhantao numNeighborPatchwise = 10, # zhantao alpha_scaled_isometry = 0., alphas_sciso = None, alpha_scaled_surfProp = 0., # zhantao alpha_stitching = 0., # zhantao useSurfaceNormal = False, # zhantao useSurfaceVariance = False, # zhantao angleThreshold = 3.14159, # zhantao rejGlobalandPatch = False, # zhantao predNormalasPatchwise = False, # zhantao overlap_criterion = False, # zhantao overlap_threshold = 0.05, # zhantao enableAnaNormalErr = False, # zhantao marginSize = 0.1, # zhantao gpu = True, **kwargs): MultipatchDecoder.__init__( self, M, num_patches, loss_scaled_isometry = loss_scaled_isometry, loss_patch_areas = loss_patch_areas, # zhantao loss_smooth_surfaces = loss_smooth_surfaces, # zhantao loss_patch_stitching = loss_patch_stitching, # zhantao alpha_scaled_isometry = alpha_scaled_isometry, k_neighbor_Global = numNeighborGlobal, # zhantao k_neighbor_Patch = numNeighborPatchwise, # zhantao alphas_sciso = alphas_sciso, alpha_surfProp = alpha_scaled_surfProp, # zhantao alpha_stitching = alpha_stitching, # zhantao surfaceNormal = useSurfaceNormal, # zhantao surfaceVariance = useSurfaceVariance, # zhantao angleThreshold = angleThreshold, # zhantao GlobalandPatch = rejGlobalandPatch, # zhantao predNormalforPatch = predNormalasPatchwise, # zhantao overlapCriterion= overlap_criterion, # zhantao overlapThreshold= overlap_threshold, # zhantao anaNormalCriterion= enableAnaNormalErr, # zhantao marginSize = marginSize, # zhantao gpu=gpu) Device.__init__(self, gpu) self._code = code self.enc = RN.resnet18(pretrained=False, num_classes=code) \ .to(self.device) self.sampler = FNSamplerRandUniform((0., 1.), (0., 1.), M, gpu=gpu) self.dec = DecoderMultiPatch( num_patches, DecoderAtlasNet, code=code, sample_dim=2, batch_norm=dec_batch_norm, activ_fns=dec_activ_fns, use_tanh=dec_use_tanh, gpu=gpu, **kwargs) # Load encoder weights. if enc_load_weights is not None: self.load_state_dict(torch.load(enc_load_weights), strict=False) print('[INFO] Loaded weights for PointNet encoder from {}'. format(enc_load_weights)) # Freeze encoder. if freeze_encoder: self._freeze_encoder(freeze=True)
def __init__(self, gpu=True): ABC.__init__(self) nn.Module.__init__(self) Device.__init__(self, gpu=gpu)