Python tf_util.fully_connected() Examples
The following are 30
code examples of tf_util.fully_connected().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tf_util
, or try the search function
.
Example #1
Source File: resnet152_io.py From DBNet with Apache License 2.0 | 6 votes |
def get_model(net, is_training, add_lstm=False, bn_decay=None, separately=False): """ ResNet152 regression model, input is BxWxHx3, output Bx2""" net = get_resnet(224, 224)(net) if not add_lstm: net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc_final') else: net = tf_util.fully_connected(net, 784, bn=True, is_training=is_training, scope='fc_lstm', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope="dp1") net = cnn_lstm_block(net) return net
Example #2
Source File: inception_v4_io.py From DBNet with Apache License 2.0 | 6 votes |
def get_model(net, is_training, add_lstm=False, bn_decay=None, separately=False): """ Inception_V4 regression model, input is BxWxHx3, output Bx2""" net = get_inception(299, 299)(net) if not add_lstm: net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc_final') else: net = tf_util.fully_connected(net, 784, bn=True, is_training=is_training, scope='fc_lstm', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope="dp1") net = cnn_lstm_block(net) return net
Example #3
Source File: densenet169_io.py From DBNet with Apache License 2.0 | 6 votes |
def get_model(net, is_training, add_lstm=False, bn_decay=None, separately=False): """ Densenet169 regression model, input is BxWxHx3, output Bx2""" net = get_densenet(224, 224)(net) if not add_lstm: net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc_final') else: net = tf_util.fully_connected(net, 784, bn=True, is_training=is_training, scope='fc_lstm', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope="dp1") net = cnn_lstm_block(net) return net
Example #4
Source File: pointnet2_cls_msg.py From dfc2019 with MIT License | 6 votes |
def get_model(point_cloud, is_training, bn_decay=None): """ Classification PointNet, input is BxNx3, output Bx40 """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value end_points = {} l0_xyz = point_cloud l0_points = None # Set abstraction layers l1_xyz, l1_points = pointnet_sa_module_msg(l0_xyz, l0_points, 512, [0.1,0.2,0.4], [16,32,128], [[32,32,64], [64,64,128], [64,96,128]], is_training, bn_decay, scope='layer1', use_nchw=True) l2_xyz, l2_points = pointnet_sa_module_msg(l1_xyz, l1_points, 128, [0.2,0.4,0.8], [32,64,128], [[64,64,128], [128,128,256], [128,128,256]], is_training, bn_decay, scope='layer2') l3_xyz, l3_points, _ = pointnet_sa_module(l2_xyz, l2_points, npoint=None, radius=None, nsample=None, mlp=[256,512,1024], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer3') # Fully connected layers net = tf.reshape(l3_points, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.4, is_training=is_training, scope='dp1') net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.4, is_training=is_training, scope='dp2') net = tf_util.fully_connected(net, 40, activation_fn=None, scope='fc3') return net, end_points
Example #5
Source File: pointnet2_cls_ssg.py From dfc2019 with MIT License | 6 votes |
def get_model(point_cloud, is_training, bn_decay=None): """ Classification PointNet, input is BxNx3, output Bx40 """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value end_points = {} l0_xyz = point_cloud l0_points = None end_points['l0_xyz'] = l0_xyz # Set abstraction layers # Note: When using NCHW for layer 2, we see increased GPU memory usage (in TF1.4). # So we only use NCHW for layer 1 until this issue can be resolved. l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=512, radius=0.2, nsample=32, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1', use_nchw=True) l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=128, radius=0.4, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') l3_xyz, l3_points, l3_indices = pointnet_sa_module(l2_xyz, l2_points, npoint=None, radius=None, nsample=None, mlp=[256,512,1024], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer3') # Fully connected layers net = tf.reshape(l3_points, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2') net = tf_util.fully_connected(net, 40, activation_fn=None, scope='fc3') return net, end_points
Example #6
Source File: model_rpointnet.py From GSPN with MIT License | 6 votes |
def single_encoding_net(pc, mlp_list, mlp_list2, scope, is_training, bn_decay): ''' The encoding network for instance Input: pc: [B, N, 3] Return: net: [B, nfea] ''' with tf.variable_scope(scope) as myscope: net = tf.expand_dims(pc, 2) for i,num_out_channel in enumerate(mlp_list): net = tf_util.conv2d(net, num_out_channel, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv%d'%i, bn_decay=bn_decay) net = tf.reduce_max(net, axis=[1]) net = tf.squeeze(net, 1) for i,num_out_channel in enumerate(mlp_list2): net = tf_util.fully_connected(net, num_out_channel, bn=True, is_training=is_training, scope='fc%d'%i, bn_decay=bn_decay) return net
Example #7
Source File: pointnet2_cls_ssg.py From scanobjectnn with MIT License | 6 votes |
def get_model(point_cloud, is_training, bn_decay=None, num_class=NUM_CLASSES): """ Classification PointNet, input is BxNx3, output Bx40 """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value end_points = {} l0_xyz = point_cloud l0_points = None end_points['l0_xyz'] = l0_xyz # Set abstraction layers # Note: When using NCHW for layer 2, we see increased GPU memory usage (in TF1.4). # So we only use NCHW for layer 1 until this issue can be resolved. l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=512, radius=0.2, nsample=32, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1', use_nchw=True) l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=128, radius=0.4, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') l3_xyz, l3_points, l3_indices = pointnet_sa_module(l2_xyz, l2_points, npoint=None, radius=None, nsample=None, mlp=[256,512,1024], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer3') # Fully connected layers net = tf.reshape(l3_points, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2') net = tf_util.fully_connected(net, num_class, activation_fn=None, scope='fc3') return net, end_points
Example #8
Source File: pointnet_plane_detection2.py From PointNet-Plane-Detection with GNU General Public License v3.0 | 5 votes |
def get_transform_K(inputs, is_training, bn_decay=None, K = 3): """ Transform Net, input is BxNx1xK gray image Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 256, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) + tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) #transform = tf_util.fully_connected(net, 3*K, activation_fn=None, scope='tfc3') transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #9
Source File: frustum_geocnn_v1.py From Geo-CNN with Apache License 2.0 | 5 votes |
def get_3d_box_estimation_v1_net(object_point_cloud, one_hot_vec, is_training, bn_decay, end_points): ''' 3D Box Estimation PointNet v1 network. Input: object_point_cloud: TF tensor in shape (B,M,C) point clouds in object coordinate one_hot_vec: TF tensor in shape (B,3) length-3 vectors indicating predicted object type Output: output: TF tensor in shape (B,3+NUM_HEADING_BIN*2+NUM_SIZE_CLUSTER*4) including box centers, heading bin class scores and residuals, and size cluster scores and residuals ''' num_point = object_point_cloud.get_shape()[1].value net = tf_util.perceptron(object_point_cloud, 128, bn=True, is_training=is_training, scope='conv-reg1', bn_decay=bn_decay) net = tf_util.perceptron(net, 128, bn=True, is_training=is_training, scope='conv-reg2', bn_decay=bn_decay) net = tf_util.perceptron(net, 256, bn=True, is_training=is_training, scope='conv-reg3', bn_decay=bn_decay) net = tf_util.perceptron(net, 512, bn=True, is_training=is_training, scope='conv-reg4', bn_decay=bn_decay) net = tf_util.max_pool2d(tf.expand_dims(net, 3), [num_point,1], padding='VALID', scope='maxpool2') net = tf.squeeze(net, axis=[1, 3]) net = tf.concat([net, one_hot_vec], axis=1) net = tf_util.fully_connected(net, 512, scope='fc1', bn=True, is_training=is_training, bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, scope='fc2', bn=True, is_training=is_training, bn_decay=bn_decay) # The first 3 numbers: box center coordinates (cx,cy,cz), # the next NUM_HEADING_BIN*2: heading bin class scores and bin residuals # next NUM_SIZE_CLUSTER*4: box cluster scores and residuals output = tf_util.fully_connected(net, 3+NUM_HEADING_BIN*2+NUM_SIZE_CLUSTER*4, activation_fn=None, scope='fc3') return output, end_points
Example #10
Source File: ipcr_model.py From pointnet-registration-framework with MIT License | 5 votes |
def get_pose(source_global_feature, template_global_feature, is_training, bn_decay=None): net = tf.concat([source_global_feature,template_global_feature],1) net = tf_util.fully_connected(net, 1024, bn=False, is_training=is_training,scope='fc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 512, bn=False, is_training=is_training,scope='fc2', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=False, is_training=is_training,scope='fc3', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training,scope='dp4') predicted_transformation = tf_util.fully_connected(net, 7, activation_fn=None, scope='fc4') return predicted_transformation
Example #11
Source File: pointnet_plane_detection2.py From PointNet-Plane-Detection with GNU General Public License v3.0 | 5 votes |
def get_transform(point_cloud, is_training, bn_decay=None, K = 3): """ Transform Net, input is BxNx3 gray image Return: Transformation matrix of size 3xK """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value input_image = tf.expand_dims(point_cloud, -1) net = tf_util.conv2d(input_image, 64, [1,3], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv4', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_XYZ') as sc: assert(K==3) weights = tf.get_variable('weights', [128, 3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) + tf.constant([1,0,0,0,1,0,0,0,1], dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) #transform = tf_util.fully_connected(net, 3*K, activation_fn=None, scope='tfc3') transform = tf.reshape(transform, [batch_size, 3, K]) return transform
Example #12
Source File: model_util.py From frustum-pointnets with Apache License 2.0 | 5 votes |
def get_center_regression_net(object_point_cloud, one_hot_vec, is_training, bn_decay, end_points): ''' Regression network for center delta. a.k.a. T-Net. Input: object_point_cloud: TF tensor in shape (B,M,C) point clouds in 3D mask coordinate one_hot_vec: TF tensor in shape (B,3) length-3 vectors indicating predicted object type Output: predicted_center: TF tensor in shape (B,3) ''' num_point = object_point_cloud.get_shape()[1].value net = tf.expand_dims(object_point_cloud, 2) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg1-stage1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg2-stage1', bn_decay=bn_decay) net = tf_util.conv2d(net, 256, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg3-stage1', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='maxpool-stage1') net = tf.squeeze(net, axis=[1,2]) net = tf.concat([net, one_hot_vec], axis=1) net = tf_util.fully_connected(net, 256, scope='fc1-stage1', bn=True, is_training=is_training, bn_decay=bn_decay) net = tf_util.fully_connected(net, 128, scope='fc2-stage1', bn=True, is_training=is_training, bn_decay=bn_decay) predicted_center = tf_util.fully_connected(net, 3, activation_fn=None, scope='fc3-stage1') return predicted_center, end_points
Example #13
Source File: transform_nets.py From scanobjectnn with MIT License | 5 votes |
def feature_transform_net(inputs, is_training, bn_decay=None, K=64): """ Feature Transform Net, input is BxNx1xK Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases += tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #14
Source File: transform_nets.py From pointnetvlad with MIT License | 5 votes |
def feature_transform_net(inputs, is_training, bn_decay=None, K=64): """ Feature Transform Net, input is BxNx1xK Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases += tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #15
Source File: nvidia_io.py From DBNet with Apache License 2.0 | 5 votes |
def get_model(net, is_training, bn_decay=None, separately=False): """ NVIDIA regression model, input is BxWxHx3, output Bx2""" batch_size = net.get_shape()[0].value for i, dim in enumerate([24, 36, 48, 64, 64]): scope = "conv" + str(i + 1) net = tf_util.conv2d(net, dim, [5, 5], padding='VALID', stride=[1, 1], bn=True, is_training=is_training, scope=scope, bn_decay=bn_decay) net = tf.reshape(net, [batch_size, -1]) for i, dim in enumerate([256, 100, 50, 10]): fc_scope = "fc" + str(i + 1) dp_scope = "dp" + str(i + 1) net = tf_util.fully_connected(net, dim, bn=True, is_training=is_training, scope=fc_scope, bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope=dp_scope) net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc5') return net
Example #16
Source File: architectures.py From SPFN with MIT License | 5 votes |
def build_pointnet2_cls(scope, point_cloud, out_dims, is_training, bn_decay): with tf.variable_scope(scope): batch_size = tf.shape(point_cloud)[0] l0_xyz = point_cloud l0_points = None # Set abstraction layers # Note: When using NCHW for layer 2, we see increased GPU memory usage (in TF1.4). # So we only use NCHW for layer 1 until this issue can be resolved. l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=512, radius=0.2, nsample=32, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1', use_nchw=True) l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=128, radius=0.4, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') l3_xyz, l3_points, l3_indices = pointnet_sa_module(l2_xyz, l2_points, npoint=None, radius=None, nsample=None, mlp=[256,512,1024], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer3') # Fully connected layers net = tf.reshape(l3_points, [batch_size, 1024]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2') results = [] for idx, out_dim in enumerate(out_dims): current_result = tf_util.fully_connected(net, out_dim, activation_fn=None, scope='fc3_{}'.format(idx)) results.append(current_result) return results
Example #17
Source File: densenet169_pn.py From DBNet with Apache License 2.0 | 5 votes |
def get_model(net, is_training, add_lstm=False, bn_decay=None, separately=False): """ Densenet169 regression model, input is BxWxHx3, output Bx2""" batch_size = net[0].get_shape()[0].value img_net, pt_net = net[0], net[1] img_net = get_densenet(299, 299)(img_net) with tf.variable_scope('pointnet'): pt_net = pointnet.get_model(pt_net, tf.constant(True)) net = tf.reshape(tf.stack([img_net, pt_net], axis=2), [batch_size, -1]) if not add_lstm: for i, dim in enumerate([256, 128, 16]): fc_scope = "fc" + str(i + 1) dp_scope = "dp" + str(i + 1) net = tf_util.fully_connected(net, dim, bn=True, is_training=is_training, scope=fc_scope, bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope=dp_scope) net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc4') else: fc_scope = "fc1" net = tf_util.fully_connected(net, 784, bn=True, is_training=is_training, scope=fc_scope, bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope="dp1") net = cnn_lstm_block(net) return net
Example #18
Source File: inception_v4_pm.py From DBNet with Apache License 2.0 | 5 votes |
def get_model(net, is_training, add_lstm=False, bn_decay=None, separately=False): """ Inception_V4 regression model, input is BxWxHx3, output Bx2""" batch_size = net[0].get_shape()[0].value img_net, fmap_net = net[0], net[1] img_net = get_inception(299, 299)(img_net) fmap_net = get_inception(299, 299)(fmap_net) net = tf.reshape(tf.stack([img_net, fmap_net]), [batch_size, -1]) if not add_lstm: for i, dim in enumerate([256, 128, 16]): fc_scope = "fc" + str(i + 1) dp_scope = "dp" + str(i + 1) net = tf_util.fully_connected(net, dim, bn=True, is_training=is_training, scope=fc_scope, bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope=dp_scope) net = tf_util.fully_connected(net, 2, activation_fn=None, scope='fc4') else: fc_scope = "fc1" net = tf_util.fully_connected(net, 784, bn=True, is_training=is_training, scope=fc_scope, bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope="dp1") net = cnn_lstm_block(net) return net
Example #19
Source File: pointnet_plane_detection.py From PointNet-Plane-Detection with GNU General Public License v3.0 | 5 votes |
def get_transform(point_cloud, is_training, bn_decay=None, K = 3): """ Transform Net, input is BxNx3 gray image Return: Transformation matrix of size 3xK """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value input_image = tf.expand_dims(point_cloud, -1) net = tf_util.conv2d(input_image, 64, [1,3], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv4', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_XYZ') as sc: assert(K==3) weights = tf.get_variable('weights', [128, 3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) + tf.constant([1,0,0,0,1,0,0,0,1], dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) #transform = tf_util.fully_connected(net, 3*K, activation_fn=None, scope='tfc3') transform = tf.reshape(transform, [batch_size, 3, K]) return transform
Example #20
Source File: pointnet_plane_detection.py From PointNet-Plane-Detection with GNU General Public License v3.0 | 5 votes |
def get_transform_K(inputs, is_training, bn_decay=None, K = 3): """ Transform Net, input is BxNx1xK gray image Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 256, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) + tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) #transform = tf_util.fully_connected(net, 3*K, activation_fn=None, scope='tfc3') transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #21
Source File: model_util.py From Geo-CNN with Apache License 2.0 | 5 votes |
def get_center_regression_net(object_point_cloud, one_hot_vec, is_training, bn_decay, end_points): ''' Regression network for center delta. a.k.a. T-Net. Input: object_point_cloud: TF tensor in shape (B,M,C) point clouds in 3D mask coordinate one_hot_vec: TF tensor in shape (B,3) length-3 vectors indicating predicted object type Output: predicted_center: TF tensor in shape (B,3) ''' num_point = object_point_cloud.get_shape()[1].value net = tf.expand_dims(object_point_cloud, 2) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg1-stage1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg2-stage1', bn_decay=bn_decay) net = tf_util.conv2d(net, 256, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv-reg3-stage1', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='maxpool-stage1') net = tf.squeeze(net, axis=[1,2]) net = tf.concat([net, one_hot_vec], axis=1) net = tf_util.fully_connected(net, 256, scope='fc1-stage1', bn=True, is_training=is_training, bn_decay=bn_decay) net = tf_util.fully_connected(net, 128, scope='fc2-stage1', bn=True, is_training=is_training, bn_decay=bn_decay) predicted_center = tf_util.fully_connected(net, 3, activation_fn=None, scope='fc3-stage1') return predicted_center, end_points
Example #22
Source File: transform_nets.py From PointCNN.Pytorch with MIT License | 5 votes |
def feature_transform_net(inputs, is_training, bn_decay=None, K=64): """ Feature Transform Net, input is BxNx1xK Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases += tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #23
Source File: transform_nets.py From 3d-adv-pc with MIT License | 5 votes |
def feature_transform_net(inputs, is_training, bn_decay=None, K=64): """ Feature Transform Net, input is BxNx1xK Return: Transformation matrix of size KxK """ batch_size = inputs.get_shape()[0].value num_point = inputs.get_shape()[1].value net = tf_util.conv2d(inputs, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv2', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_feat') as sc: weights = tf.get_variable('weights', [256, K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [K*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases += tf.constant(np.eye(K).flatten(), dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) transform = tf.reshape(transform, [batch_size, K, K]) return transform
Example #24
Source File: model.py From PointCNN.Pytorch with MIT License | 5 votes |
def get_model(point_cloud, is_training, bn_decay=None): """ ConvNet baseline, input is BxNx3 gray image """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value input_image = tf.expand_dims(point_cloud, -1) # CONV net = tf_util.conv2d(input_image, 64, [1,9], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv2', bn_decay=bn_decay) net = tf_util.conv2d(net, 64, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv3', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv4', bn_decay=bn_decay) points_feat1 = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv5', bn_decay=bn_decay) # MAX pc_feat1 = tf_util.max_pool2d(points_feat1, [num_point,1], padding='VALID', scope='maxpool1') # FC pc_feat1 = tf.reshape(pc_feat1, [batch_size, -1]) pc_feat1 = tf_util.fully_connected(pc_feat1, 256, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) pc_feat1 = tf_util.fully_connected(pc_feat1, 128, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) print(pc_feat1) # CONCAT pc_feat1_expand = tf.tile(tf.reshape(pc_feat1, [batch_size, 1, 1, -1]), [1, num_point, 1, 1]) points_feat1_concat = tf.concat(axis=3, values=[points_feat1, pc_feat1_expand]) # CONV net = tf_util.conv2d(points_feat1_concat, 512, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv6') net = tf_util.conv2d(net, 256, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='conv7') net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training, scope='dp1') net = tf_util.conv2d(net, 13, [1,1], padding='VALID', stride=[1,1], activation_fn=None, scope='conv8') net = tf.squeeze(net, [2]) return net
Example #25
Source File: pointnet_part_seg.py From PointCNN.Pytorch with MIT License | 5 votes |
def get_transform(point_cloud, is_training, bn_decay=None, K = 3): """ Transform Net, input is BxNx3 gray image Return: Transformation matrix of size 3xK """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value input_image = tf.expand_dims(point_cloud, -1) net = tf_util.conv2d(input_image, 64, [1,3], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv1', bn_decay=bn_decay) net = tf_util.conv2d(net, 128, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv3', bn_decay=bn_decay) net = tf_util.conv2d(net, 1024, [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='tconv4', bn_decay=bn_decay) net = tf_util.max_pool2d(net, [num_point,1], padding='VALID', scope='tmaxpool') net = tf.reshape(net, [batch_size, -1]) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 128, bn=True, is_training=is_training, scope='tfc2', bn_decay=bn_decay) with tf.variable_scope('transform_XYZ') as sc: assert(K==3) weights = tf.get_variable('weights', [128, 3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) biases = tf.get_variable('biases', [3*K], initializer=tf.constant_initializer(0.0), dtype=tf.float32) + tf.constant([1,0,0,0,1,0,0,0,1], dtype=tf.float32) transform = tf.matmul(net, weights) transform = tf.nn.bias_add(transform, biases) #transform = tf_util.fully_connected(net, 3*K, activation_fn=None, scope='tfc3') transform = tf.reshape(transform, [batch_size, 3, K]) return transform
Example #26
Source File: ipcr_model.py From pcrnet with MIT License | 5 votes |
def get_pose(source_global_feature, template_global_feature, is_training, bn_decay=None): net = tf.concat([source_global_feature,template_global_feature],1) net = tf_util.fully_connected(net, 1024, bn=False, is_training=is_training,scope='fc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 512, bn=False, is_training=is_training,scope='fc2', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=False, is_training=is_training,scope='fc3', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.7, is_training=is_training,scope='dp4') predicted_transformation = tf_util.fully_connected(net, 7, activation_fn=None, scope='fc4') return predicted_transformation
Example #27
Source File: pcr_model.py From pcrnet with MIT License | 5 votes |
def get_pose(self,source_global_feature,template_global_feature,is_training,bn_decay=None): # with tf.variable_scope('pose_estimation') as pn: net = tf.concat([source_global_feature,template_global_feature],1) net = tf_util.fully_connected(net, 1024, bn=False, is_training=is_training,scope='fc1', bn_decay=bn_decay) net = tf_util.fully_connected(net, 1024, bn=False, is_training=is_training,scope='fc2', bn_decay=bn_decay) net = tf_util.fully_connected(net, 512, bn=False, is_training=is_training,scope='fc3', bn_decay=bn_decay) net = tf_util.fully_connected(net, 512, bn=False, is_training=is_training,scope='fc4', bn_decay=bn_decay) net = tf_util.fully_connected(net, 256, bn=False, is_training=is_training,scope='fc5', bn_decay=bn_decay) predicted_transformation = tf_util.fully_connected(net, 7, activation_fn=None, scope='fc6') return predicted_transformation
Example #28
Source File: ldgcnn.py From ldgcnn with MIT License | 5 votes |
def get_model(point_cloud, is_training, bn_decay=None): """ Classification PointNet, input is BxNx3, output Bx40 """ batch_size = point_cloud.get_shape()[0].value layers = {} # Extract global feature net = calc_ldgcnn_feature(point_cloud, is_training, bn_decay) # MLP on global point cloud vector net = tf.reshape(net, [batch_size, -1]) layers['global_feature'] = net # Fully connected layers: classifier # net: B*512 net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) layers['fc1'] = net # Each element is kept or dropped independently, and the drop rate is 0.5. net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') # net: B*256 net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay) layers['fc2'] = net net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2') # net: B*40 net = tf_util.fully_connected(net, 40, activation_fn=None, scope='fc3') layers['fc3'] = net return net,layers
Example #29
Source File: ldgcnn_classifier.py From ldgcnn with MIT License | 5 votes |
def get_model(feature, is_training, bn_decay=None): # Fully connected layers: classifier layers = {} feature = tf.squeeze(feature) layer_name = 'ft_' # B: batch size; C: channels; # feature: B*C # net: B*512 net = tf_util.fully_connected(feature, 512, bn=True, is_training=is_training, scope=layer_name + 'fc2', bn_decay=bn_decay, activation_fn = tf.nn.relu) layers[layer_name + 'fc2'] = net net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope=layer_name + 'dp2') # net: B*256 net = tf_util.fully_connected(net, 256, bn=True, is_training=is_training, scope=layer_name + 'fc3', bn_decay=bn_decay, activation_fn = tf.nn.relu) layers[layer_name + 'fc3'] = net net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope=layer_name + 'dp3') # net: B*40 net = tf_util.fully_connected(net, 40, activation_fn=None, scope='fc4') layers[layer_name + 'fc4'] = net return net, layers
Example #30
Source File: model_cls_direct.py From meteornet with MIT License | 5 votes |
def get_model(point_cloud, num_frames, is_training, bn_decay=None): """ Input: point_cloud: [batch_size, num_point * num_frames, 3] Output: net: [batch_size, num_class] """ end_points = {} batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value // num_frames l0_xyz = point_cloud l0_time = tf.concat([tf.ones([batch_size, num_point, 1]) * i for i in range(num_frames)], \ axis=-2) l0_points = tf.concat([point_cloud[:, :, 3:], l0_time], axis=-1) RADIUS1 = np.linspace(0.5, 0.6, num_frames, dtype='float32') RADIUS2 = RADIUS1 * 2 RADIUS3 = RADIUS1 * 4 RADIUS4 = RADIUS1 * 8 l1_xyz, l1_time, l1_points, l1_indices = meteor_direct_module(l0_xyz, l0_time, l0_points, npoint=1024, radius=RADIUS1, nsample=32, mlp=[32,32,64], mlp2=None, group_all=False, knn=False, is_training=is_training, bn_decay=bn_decay, scope='layer1') l2_xyz, l2_time, l2_points, l2_indices = meteor_direct_module(l1_xyz, l1_time, l1_points, npoint=512, radius=RADIUS2, nsample=32, mlp=[64,64,128], mlp2=None, group_all=False, knn=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') l3_xyz, l3_time, l3_points, l3_indices = meteor_direct_module(l2_xyz, l2_time, l2_points, npoint=128, radius=RADIUS3, nsample=32, mlp=[128,128,256], mlp2=None, group_all=False, knn=False, is_training=is_training, bn_decay=bn_decay, scope='layer3') l4_xyz, l4_points, l4_indices = pointnet_sa_module(l3_xyz, l3_points, npoint=None, radius=None, nsample=None, mlp=[256,512,1024], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer4') # Fully connected layers net = tf.reshape(l3_points, [batch_size, -1]) net = tf_util.fully_connected(net, 512, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.fully_connected(net, 20, activation_fn=None, scope='fc3') return net, end_points