def build_network(self): self.SA_modules = nn.ModuleList() c_in = 0 self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.2, nsample=64, mlp=[c_in, 64, 64, 128], use_xyz=self.config["use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=32, mlp=[128, 128, 128, 256], radius=0.4, nsample=64, use_xyz=self.config["use_xyz"], )) self.SA_modules.append( PointnetSAModule( mlp=[256, 256, 256, 512], use_xyz=self.config["use_xyz"], )) self.fc = nn.Sequential( nn.Linear(512 + self.config['num_cls'], 512), nn.BatchNorm1d(512), nn.ReLU(True), nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(True), nn.Linear( 256, 3 + 2 * self.config['num_heading_bin'] + 4 * self.config['num_size_cluster']))
def _build_model(self): self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=512, radius=0.2, nsample=64, mlp=[3, 64, 64, 128], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=self.hparams["model.use_xyz"])) self.fc_layer = nn.Sequential( nn.Linear(1024, 512, bias=False), nn.BatchNorm1d(512), nn.ReLU(True), nn.Linear(512, 256, bias=False), nn.BatchNorm1d(256), nn.ReLU(True), nn.Dropout(0.5), nn.Linear(256, 40), )
def _build_model(self): self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=1024, radius=0.1, nsample=32, mlp=[6, 32, 32, 64], use_xyz=self.hparams["model.use_xyz"], ) ) self.SA_modules.append( PointnetSAModule( npoint=256, radius=0.2, nsample=32, mlp=[64, 64, 64, 128], use_xyz=self.hparams["model.use_xyz"], ) ) self.SA_modules.append( PointnetSAModule( npoint=64, radius=0.4, nsample=32, mlp=[128, 128, 128, 256], use_xyz=self.hparams["model.use_xyz"], ) ) self.SA_modules.append( PointnetSAModule( npoint=16, radius=0.8, nsample=32, mlp=[256, 256, 256, 512], use_xyz=self.hparams["model.use_xyz"], ) ) self.FP_modules = nn.ModuleList() self.FP_modules.append(PointnetFPModule(mlp=[128 + 6, 128, 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 64, 256, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 128, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + 256, 256, 256])) self.fc_lyaer = nn.Sequential( nn.Conv1d(128, 128, kernel_size=1, bias=False), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.5), nn.Conv1d(128, 12, kernel_size=1),# 13 is the number of classes, now 20 or 12 )
def _build_model(self): self.SA_modules = nn.ModuleList() # pdb.set_trace() self.SA_modules.append( PointnetSAModule( npoint=1024, radius=0.1, nsample=32, mlp=[self.hparams['in_fea_dim'], 32, 32, 64], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=256, radius=0.2, nsample=32, mlp=[64, 64, 64, 128], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=64, radius=0.4, nsample=32, mlp=[128, 128, 128, 256], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=16, radius=0.8, nsample=32, mlp=[256, 256, 256, 512], use_xyz=self.hparams["model.use_xyz"], )) self.FP_modules = nn.ModuleList() self.FP_modules.append( PointnetFPModule( mlp=[128 + self.hparams['in_fea_dim'], 128, 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 64, 256, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 128, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + 256, 256, 256])) self.fc_lyaer = nn.Sequential( nn.Conv1d(128, 128, kernel_size=1, bias=False), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.5), nn.Conv1d(128, self.hparams['out_dim'], kernel_size=1), )
def _build_model(self): self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=1024, radius=0.1, nsample=32, mlp=[3, 32, 32, 64], use_xyz=True, ) ) self.SA_modules.append( PointnetSAModule( npoint=256, radius=0.2, nsample=32, mlp=[64, 64, 64, 128], use_xyz=True, ) ) self.SA_modules.append( PointnetSAModule( npoint=64, radius=0.4, nsample=32, mlp=[128, 128, 128, 256], use_xyz=True, ) ) self.SA_modules.append( PointnetSAModule( npoint=16, radius=0.8, nsample=32, mlp=[256, 256, 256, 512], use_xyz=True, ) ) self.FP_modules = nn.ModuleList() self.FP_modules.append(PointnetFPModule(mlp=[128 + 3, 128, 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 64, 256, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 128, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + 256, 256, 256])) self.fc_layer = nn.Sequential( nn.Conv1d(128, self.hparams['feat_dim'], kernel_size=1, bias=False), nn.BatchNorm1d(self.hparams['feat_dim']), nn.ReLU(True), )
def _build_model(self): super()._build_model() if self.use_normal: ori_channel = 3 else: ori_channel = 0 self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[[ori_channel, 32, 32, 64], [ori_channel, 64, 64, 128], [ori_channel, 64, 96, 128]], use_xyz=self.use_xyz, )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=self.use_xyz, )) self.SA_modules.append( PointnetSAModule( mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=self.use_xyz, ))
def _build_model(self): super()._build_model() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[[3, 32, 32, 64], [3, 64, 64, 128], [3, 64, 96, 128]], use_xyz=self.hparams["model.use_xyz"], )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=self.hparams["model.use_xyz"], ))
def __init__(self, output_classes=751, init_points=512, input_dims=3, dropout_prob=0.5, use_xyz=True): super().__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=init_points, radius=0.2, nsample=64, mlp=[input_dims, 64, 64, 128], use_xyz=use_xyz, use_se=False, )) #batchsize 512 128 self.SA_modules.append( PointnetSAModule(npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=use_xyz, use_se=False)) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz, use_se=False)) self.fc_layer = nn.Sequential(nn.Linear(1024, 512, bias=True), nn.BatchNorm1d(512), nn.LeakyReLU(0.2, True), nn.Linear(512, 512, bias=True), nn.BatchNorm1d(512), nn.Dropout(dropout_prob)) self.classifier = nn.Sequential(nn.Linear(512, output_classes)) # initial self.SA_modules.apply(weights_init_kaiming) self.fc_layer.apply(weights_init_kaiming) self.classifier.apply(weights_init_classifier)
def build_network(self): self.SA_modules = nn.ModuleList() c_in = self.config['features'] self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[[c_in, 32, 32, 64], [c_in, 64, 64, 128], [c_in, 64, 96, 128]], use_xyz=self.config["use_xyz"], )) input_channels_1 = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=32, radii=[0.4, 0.8, 1.6], nsamples=[64, 64, 128], mlps=[ [input_channels_1, 64, 64, 128], [input_channels_1, 128, 128, 256], [input_channels_1, 128, 128, 256], ], use_xyz=self.config["use_xyz"], )) input_channels_2 = 128 + 256 + 256 self.SA_modules.append( PointnetSAModule( mlp=[input_channels_2, 128, 256, 1024], use_xyz=self.config["use_xyz"], )) self.FP_modules = nn.ModuleList() self.FP_modules.append(PointnetFPModule(mlp=[c_in + 128, 128, 128])) self.FP_modules.append( PointnetFPModule(mlp=[input_channels_1 + 128, 128, 128])) self.FP_modules.append( PointnetFPModule(mlp=[ input_channels_2 + 1024 + self.config['num_cls'], 128, 128 ])) self.features = nn.Conv1d(128, 128, kernel_size=1, bias=False) self.fc_lyaer = nn.Sequential( nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.5), nn.Conv1d(128, 2, kernel_size=1), )
def __init__(self, input_channels=3, use_xyz=True): super(PCEncoder, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule(npoint=512, radius=0.2, nsample=64, mlp=[input_channels, 64, 64, 128], use_xyz=use_xyz, bn=False)) self.SA_modules.append( PointnetSAModule(npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=use_xyz, bn=False)) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz, bn=False)) self.FC_layer = (pt_utils.Seq(1024).fc(256, bn=False, activation=None))
def _build_model(self): if self.use_normal: ori_channel = 3 else: ori_channel = 0 self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=512, radius=0.2, nsample=64, mlp=[ori_channel, 64, 64, 128], use_xyz=self.use_xyz, )) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=self.use_xyz, )) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=self.use_xyz)) self.fc_layer = nn.Sequential( nn.Linear(1024, 512, bias=False), nn.BatchNorm1d(512), nn.ReLU(True), nn.Linear(512, 256, bias=False), nn.BatchNorm1d(256), nn.ReLU(True), nn.Dropout(0.5), nn.Linear(256, 40), )
def _build_model(self): # call the base method and then override SA_modules super()._build_model() self.SA_modules = nn.ModuleList() for i in range(len(self.radii)): self.SA_modules.append( PointnetSAModuleMSG(npoint=self.npoints[i], radii=self.radii[i], nsamples=self.nsamples[i], mlps=self.mlps[i], use_xyz=self.use_xyz)) self.SA_modules.append( PointnetSAModule(mlp=self.mlps[-1], use_xyz=self.use_xyz))
def __init__(self, output_classes=751, init_points=512, input_dims=3, dropout_prob=0.5, use_xyz=True): super().__init__(output_classes=output_classes, dropout_prob=dropout_prob) self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[[3, 32, 32, 64], [3, 64, 64, 128], [3, 64, 96, 128]], use_xyz=use_xyz, use_se=False, )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=use_xyz, use_se=False, )) self.SA_modules.append( PointnetSAModule( mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=use_xyz, use_se=False, )) self.SA_modules.apply(weights_init_kaiming)
def _build_model(self): pc_dim = 1 self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[[pc_dim, 32, 32, 64], [pc_dim, 64, 64, 128], [pc_dim, 64, 96, 128]], use_xyz=self.cfg.model.use_xyz, )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=self.cfg.model.use_xyz, )) self.SA_modules.append( PointnetSAModule( mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=self.cfg.model.use_xyz, )) _, _, _, self.name2wn = pickle.load( open( os.path.join(self.cfg.base_dir, self.cfg.folder_dir, 'misc.pkl'), 'rb')) self._class_list = pickle.load( open(os.path.join(self.cfg.base_dir, 'class_list.pkl'), 'rb')) if self.cfg.use_class_list else list( self.name2wn.values()) task_vocab_size = len(TASKS) self.task_embedding = nn.Embedding(task_vocab_size, self.cfg.embedding_size) class_vocab_size = len(self._class_list) self.class_embedding = nn.Embedding(class_vocab_size, self.cfg.embedding_size) self.fc_layer = nn.Sequential(nn.Linear(1024, 512, bias=False), nn.BatchNorm1d(512), nn.ReLU(True), nn.Linear(512, self.cfg.embedding_size)) embeddding_size = self.cfg.embedding_size * 3 self.fc_layer2 = nn.Sequential( nn.Linear(embeddding_size, 256, bias=False), nn.BatchNorm1d(256), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(256, 256), nn.BatchNorm1d(256), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(256, 256), nn.BatchNorm1d(256), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(256, 1), )
def __init__(self, k, feature_dims, emb_dims, output_classes, init_points=512, input_dims=3, dropout_prob=0.5, npart=1, id_skip=False, drop_connect_rate=0, res_scale=1.0, light=False, bias=False, cluster='xyz', conv='EdgeConv', use_xyz=True, use_se=True, graph_jitter=False, pre_act=False, norm='bn', stride=2, layer_drop=0, num_conv=1): super(ModelE, self).__init__() self.npart = npart self.norm = norm self.graph_jitter = graph_jitter self.res_scale = res_scale self.id_skip = id_skip self.drop_connect_rate = drop_connect_rate self.nng = KNNGraphE(k) # with random neighbor self.conv = nn.ModuleList() self.conv_s1 = nn.ModuleList() self.conv_s2 = nn.ModuleList() self.bn = nn.ModuleList() self.sa = nn.ModuleList() self.cluster = cluster self.feature_dims = feature_dims self.conv_type = conv self.init_points = init_points self.k = k self.light = light self.pre_act = pre_act self.num_conv = num_conv #self.proj_in = nn.Linear(input_dims, input_dims) self.num_layers = len(feature_dims) npoint = init_points last_npoint = -1 for i in range(self.num_layers): if k == 1: self.conv.append( nn.Conv2d(feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], kernel_size=1, bias=True)) self.bn.append(nn.BatchNorm1d(feature_dims[i])) elif conv == 'EdgeConv': group_num = 2 if light and i > 0 else 1 for j in range(self.num_conv): if j == 0: self.conv.append( nn.Conv2d(feature_dims[i - 1] * 2 if i > 0 else input_dims * 2, feature_dims[i], kernel_size=1, groups=group_num, bias=True)) else: self.conv.append( nn.Conv2d(feature_dims[i] * 2, feature_dims[i], kernel_size=1, groups=group_num, bias=True)) if i == 0 and j == 0 and pre_act: norm_dim = input_dims else: norm_dim = feature_dims[ i - 1] if pre_act and j == 0 else feature_dims[i] if norm == 'ln': if layer_drop > 0: self.bn.append( nn.Sequential(nn.LayerNorm(norm_dim), nn.Dropout(layer_drop))) else: self.bn.append(nn.LayerNorm(norm_dim)) else: if layer_drop > 0: self.bn.append( nn.Sequential(nn.BatchNorm1d(norm_dim), nn.Dropout(layer_drop))) else: self.bn.append(nn.BatchNorm1d(norm_dim)) if i > 0 and feature_dims[i] > feature_dims[i - 1]: npoint = npoint // stride if npoint != last_npoint: if id_skip: self.conv_s2.append( nn.Linear(feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i])) self.sa.append( PointnetSAModule(npoint=npoint, radius=0.2, nsample=64, mlp=[ feature_dims[i], feature_dims[i], feature_dims[i] ], fuse='add', norml='bn', activation='relu', use_se=use_se, use_xyz=use_xyz, use_neighbor=False, light=False)) last_npoint = npoint #if id_skip: # self.conv_s1.append( nn.Linear(feature_dims[i], feature_dims[i] )) self.embs = nn.ModuleList() self.bn_embs = nn.ModuleList() self.dropouts = nn.ModuleList() self.partpool = nn.AdaptiveAvgPool1d(self.npart) if self.npart == 1: self.embs.append( nn.Linear( # * 2 because of concatenation of max- and mean-pooling feature_dims[-1] * 2, emb_dims[0], bias=bias)) self.bn_embs.append(nn.BatchNorm1d(emb_dims[0])) self.dropouts.append(nn.Dropout(dropout_prob, inplace=True)) self.proj_output = nn.Linear(emb_dims[0], output_classes) self.proj_output.apply(weights_init_classifier) else: self.proj_outputs = nn.ModuleList() for i in range(0, self.npart): self.embs.append(nn.Linear(feature_dims[-1], 512, bias=bias)) self.bn_embs.append(nn.BatchNorm1d(512)) self.dropouts.append(nn.Dropout(dropout_prob, inplace=True)) self.proj_outputs.append(nn.Linear(512, output_classes)) self.proj_outputs.apply(weights_init_classifier) # initial #self.proj_in.apply(weights_init_kaiming) self.conv.apply(weights_init_kaiming) self.conv_s1.apply(weights_init_kaiming) self.conv_s2.apply(weights_init_kaiming) weights_init_kaiming2 = lambda x: weights_init_kaiming( x, L=self.num_layers) self.sa.apply(weights_init_kaiming2) #self.proj.apply(weights_init_kaiming) self.embs.apply(weights_init_kaiming) self.bn.apply(weights_init_kaiming) self.bn_embs.apply(weights_init_kaiming) self.npart = npart
def __init__(self, k, feature_dims, emb_dims, output_classes, init_points = 512, input_dims=3, dropout_prob=0.5, npart=1, id_skip=False, drop_connect_rate=0, res_scale = 1.0, light = False, bias = False, cluster='xyz', conv='EdgeConv', use_xyz=True, use_se = True, graph_jitter = False): super(Model, self).__init__() self.npart = npart self.graph_jitter = graph_jitter self.res_scale = res_scale self.id_skip = id_skip self.drop_connect_rate = drop_connect_rate self.nng = KNNGraphE(k) # with random neighbor self.conv = nn.ModuleList() self.conv_s1 = nn.ModuleList() self.conv_s2 = nn.ModuleList() self.bn = nn.ModuleList() self.sa = nn.ModuleList() self.cluster = cluster self.feature_dims = feature_dims self.conv_type = conv self.init_points = init_points self.k = k #self.proj_in = nn.Linear(input_dims, input_dims) self.num_layers = len(feature_dims) npoint = init_points for i in range(self.num_layers): if k==1: self.conv.append(nn.Linear(feature_dims[i-1] if i > 0 else input_dims, feature_dims[i] )) elif conv == 'EdgeConv': if light: self.conv.append(EdgeConv_Light( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], batch_norm=True)) else: self.conv.append(EdgeConv( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], batch_norm=True)) elif conv == 'GATConv': self.conv.append(GATConv( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], feat_drop=0.2, attn_drop=0.2, residual=True, num_heads=1)) elif conv == 'GraphConv': self.conv.append( GraphConv( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i])) elif conv == 'SAGEConv': self.conv.append( SAGEConv( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], feat_drop=0.2, aggregator_type='mean', norm = nn.BatchNorm1d(feature_dims[i]) ) ) elif conv == 'SGConv': self.conv.append( SGConv( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i]) ) elif conv == 'GatedGCN': # missing etypes self.conv.append( GatedGCNLayer( feature_dims[i - 1] if i > 0 else input_dims, feature_dims[i], dropout=0.0, graph_norm=True, batch_norm=True, residual=True) ) if i>0 and feature_dims[i]>feature_dims[i-1]: npoint = npoint//2 if id_skip and npoint <= self.init_points//4: # Only work on high level self.conv_s2.append( nn.Linear(feature_dims[i-1], feature_dims[i] )) self.sa.append(PointnetSAModule( npoint=npoint, radius=0.2, nsample=64, mlp=[feature_dims[i], feature_dims[i], feature_dims[i]], fuse = 'add', norml = 'bn', activation = 'relu', use_se = use_se, use_xyz = use_xyz, use_neighbor = False, light = light )) #if id_skip: # self.conv_s1.append( nn.Linear(feature_dims[i], feature_dims[i] )) self.embs = nn.ModuleList() self.bn_embs = nn.ModuleList() self.dropouts = nn.ModuleList() self.partpool = nn.AdaptiveAvgPool1d(self.npart) if self.npart == 1: self.embs.append(nn.Linear( # * 2 because of concatenation of max- and mean-pooling feature_dims[-1]*2, emb_dims[0], bias=bias)) self.bn_embs.append(nn.BatchNorm1d(emb_dims[0])) self.dropouts.append(nn.Dropout(dropout_prob, inplace=True)) self.proj_output = nn.Linear(emb_dims[0], output_classes) self.proj_output.apply(weights_init_classifier) else: self.proj_outputs = nn.ModuleList() for i in range(0, self.npart): self.embs.append(nn.Linear(512, 512, bias=bias)) self.bn_embs.append(nn.BatchNorm1d(512)) self.dropouts.append(nn.Dropout(dropout_prob, inplace=True)) self.proj_outputs.append(nn.Linear(512, output_classes)) self.proj_outputs.apply(weights_init_classifier) # initial #self.proj_in.apply(weights_init_kaiming) self.conv.apply(weights_init_kaiming) self.conv_s1.apply(weights_init_kaiming) self.conv_s2.apply(weights_init_kaiming) weights_init_kaiming2 = lambda x:weights_init_kaiming(x,L=self.num_layers) self.sa.apply(weights_init_kaiming2) #self.proj.apply(weights_init_kaiming) self.embs.apply(weights_init_kaiming) self.bn.apply(weights_init_kaiming) self.bn_embs.apply(weights_init_kaiming) self.npart = npart
def _build_model(self): pc_dim = 1 self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[[pc_dim, 32, 32, 64], [pc_dim, 64, 64, 128], [pc_dim, 64, 96, 128]], use_xyz=self.cfg.model.use_xyz, )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=self.cfg.model.use_xyz, )) self.SA_modules.append( PointnetSAModule( mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=self.cfg.model.use_xyz, )) _, _, _, self.name2wn = pickle.load( open( os.path.join(self.cfg.base_dir, self.cfg.folder_dir, 'misc.pkl'), 'rb')) self._class_list = pickle.load( open(os.path.join(self.cfg.base_dir, 'class_list.pkl'), 'rb')) if self.cfg.use_class_list else list( self.name2wn.values()) self.fc_layer = nn.Sequential(nn.Linear(1024, 512, bias=False), nn.BatchNorm1d(512), nn.ReLU(True), nn.Linear(512, self.cfg.embedding_size)) self.fc_layer3 = nn.Sequential( nn.Linear(128, 128, bias=False), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(128, 128), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(128, 128), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.2), nn.Linear(128, 1), ) self.gcn = GraphNet(in_channels=self.cfg.embedding_size + 1, hidden_channels=128, out_channels=128, num_layers=self.cfg.gcn_num_layers, conv_type=self.cfg.gcn_conv_type)
def __init__(self, num_points=2048, bradius=1.0, up_ratio=4, bn=False): super(Generator, self).__init__() self.num_points = num_points self.up_ratio = up_ratio self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=num_points, radius=bradius * 0.05, nsample=32, mlp=[0, 32, 32, 64], bn=bn, # use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=num_points // 2, radius=bradius * 0.1, nsample=32, mlp=[64, 64, 64, 128], bn=bn, # use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=num_points // 4, radius=bradius * 0.2, nsample=32, mlp=[128, 128, 128, 256], bn=bn, # use_xyz=self.hparams["model.use_xyz"], )) self.SA_modules.append( PointnetSAModule( npoint=num_points // 8, radius=bradius * 0.3, nsample=32, mlp=[256, 256, 256, 512], bn=bn, # use_xyz=self.hparams["model.use_xyz"], )) self.FP_modules = nn.ModuleList() self.FP_modules.append(PointnetFPModule(mlp=[512, 64], bn=False)) self.FP_modules.append(PointnetFPModule(mlp=[256, 64], bn=False)) self.FP_modules.append(PointnetFPModule(mlp=[128, 64], bn=False)) self.New_points_list = nn.ModuleList() for i in range(self.up_ratio): self.New_points_list.append( nn.Sequential( nn.Conv2d(259, 256, kernel_size=1, bias=False), # nn.BatchNorm2d(256), nn.ReLU(True), # nn.Dropout(0.5), nn.Conv2d(256, 128, kernel_size=1), # nn.BatchNorm2d(128), nn.ReLU(True), # nn.Dropout(0.5), )) self.fc_lyaer = nn.Sequential( nn.Conv2d(168, 64, kernel_size=1, bias=False), # nn.BatchNorm2d(64), nn.ReLU(True), # nn.Dropout(0.5), nn.Conv2d(64, 3, kernel_size=1), # nn.BatchNorm2d(3), nn.ReLU(True), # nn.Dropout(0.5), )