import os
import sys
BASE_DIR = os.path.dirname(__file__)
sys.path.append(BASE_DIR)
sys.path.append(os.path.join(BASE_DIR, '../utils'))
import tensorflow as tf
import numpy as np
import tf_util
from pointnet_util import pointnet_sa_module, pointnet_fp_module, pointnet_sa_module1, pointnet_fp_module144
def placeholder_inputs(batch_size, num_point):
pointclouds_pl = tf.placeholder(tf.float32, shape=(batch_size, num_point, 3), name='pointclouds_pl')
intensity_pl = tf.placeholder(tf.float32, shape=(batch_size, num_point), name='intensity_pl')
zz_pl = tf.placeholder(tf.float32, shape=(batch_size, num_point), name='zz_pl')
labels_pl = tf.placeholder(tf.int32, shape=(batch_size, num_point), name='labels_pl')
smpws_pl = tf.placeholder(tf.float32, shape=(batch_size, num_point), name='smpws_pl')
return pointclouds_pl, intensity_pl, zz_pl, labels_pl, smpws_pl
def get_model(point_cloud, intensity, zz, is_training, num_class, bn_decay=None):
""" Semantic segmentation PointNet, input is BxNx3, output Bxnum_class """
batch_size = point_cloud.get_shape()[0].value
num_point = point_cloud.get_shape()[1].value
end_points = {}
l0_xyz = point_cloud
l0_points = tf.expand_dims(intensity, -1)
#zz = tf.expand_dims(zz, -1)
#l0_points = tf.concat([l0_points, zz], -1)
"""
intensity_max = tf.reduce_max(intensity, axis=1, keep_dims=True)
intensity_min = tf.reduce_min(intensity, axis=1, keep_dims=True)
intensity_nom = 255.0 * (intensity - intensity_min)/(intensity_max - intensity_min)
intensity_nom = tf.math.ceil(intensity_nom, name=None)
l0_points = intensity_nom
zz = point_cloud[:,:,2]
zz = tf.expand_dims(zz, -1)
zz_max = tf.reduce_max(zz, axis=1, keep_dims=True)
zz_min = tf.reduce_min(zz, axis=1, keep_dims=True)
zz_nom = 255.0 * (zz - zz_min)/(zz_max - zz_min)
zz_nom = tf.math.ceil(zz_nom, name=None)
l0_points = tf.concat([l0_points, zz_nom], -1)
"""
"""
zz = point_cloud[:,:,2]
zz = tf.expand_dims(zz, -1)
z_max = tf.reduce_max(zz, axis=1, keep_dims=True)
z_max = tf.tile(z_max, [1,num_point,1])
z_min = tf.reduce_min(zz, axis=1, keep_dims=True)
z_min = tf.tile(z_min, [1,num_point,1])
z_r = z_max - z_min
z_cha = zz - z_min
z_mean = tf.reduce_mean(zz, axis=1, keep_dims=True)
z_mean = tf.tile(z_mean, [1,num_point,1])
z_fangcha = tf.sqrt(tf.reduce_mean(tf.square(zz - z_mean), axis=1, keep_dims=True))
z_fangcha = tf.tile(z_fangcha, [1,num_point,1])
z_all = tf.concat([zz, z_max], -1)
z_all = tf.concat([z_all, z_min], -1)
z_all = tf.concat([z_all, z_r], -1)
z_all = tf.concat([z_all, z_cha], -1)
z_all = tf.concat([z_all, z_mean], -1)
z_all = tf.concat([z_all, z_fangcha], -1)
z_all = tf_util.conv1d(z_all, z_all.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='sub12', bn_decay=bn_decay)
z_all = tf_util.conv1d(z_all, z_all.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='sub122', bn_decay=bn_decay)
z_all = tf_util.conv1d(z_all, 1, 1, padding='VALID', bn=False, is_training=is_training, scope='sub11', bn_decay=bn_decay)
z_all = tf_util.conv1d(z_all, 1, 1, padding='VALID', bn=False, is_training=is_training, scope='sub112', bn_decay=bn_decay)
l0_points = tf.concat([l0_points, z_all], -1)
"""
"""
point_cloud0 = tf_util.conv1d(point_cloud, point_cloud.shape[2], 1, padding='VALID', bn=True, is_training=is_training, scope='sub1', bn_decay=bn_decay)
point_cloud1 = tf.tile(tf.expand_dims(point_cloud, 2), [1,1,point_cloud.get_shape()[1].value,1])
point_cloud2 = tf.transpose(point_cloud1, perm=[0,2,1,3])
point_cloud_sub = tf.subtract(point_cloud1, point_cloud2)
point_cloud_sub = tf.nn.softmax(point_cloud_sub)
point_cloud_sub = tf_util.conv2d(point_cloud_sub, point_cloud.shape[-1], [1,1], padding='VALID', stride=[1,1], bn=True, is_training=is_training, scope='sub2', bn_decay=bn_decay, data_format='NHWC')
point_cloud_sub = tf.multiply(point_cloud_sub, point_cloud0)
l0_points = tf.concat([l0_points, point_cloud_sub], -1)
"""
"""
xy = point_cloud[:,:,0:2]
xz = point_cloud[:,:,0::2]
yz = point_cloud[:,:,1:]
l0_points = tf.concat([l0_points, xy], -1)
l0_points = tf.concat([l0_points, xz], -1)
l0_points = tf.concat([l0_points, yz], -1)
"""
"""
zz = point_cloud[:,:,2]
zz = tf.expand_dims(zz, -1)
zz_min = tf.reduce_min(zz, axis=1, keep_dims=True)
zz = zz - zz_min
l0_points = tf.concat([l0_points, zz], -1)
"""
end_points['l0_xyz'] = l0_xyz
# Layer 1
"""
l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=4096, radius=4, nsample=64, mlp=[32,32,64], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1')
l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=1024, radius=8, nsample=64, mlp=[64,64,128], 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=256, radius=16, nsample=64, mlp=[128,128,256], mlp2=None, group_all=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=64, radius=32, nsample=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4')
l5_xyz, l5_points, l5_indices = pointnet_sa_module(l4_xyz, l4_points, npoint=16, radius=64, nsample=64, mlp=[512,512,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer5')
"""
"""
l0_points = tf.concat([l0_xyz, l0_points], -1)
l0_points = tf_util.conv1d(l0_points, l0_points.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='fc1111', bn_decay=bn_decay)
l0_points = tf_util.conv1d(l0_points, l0_points.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='fc2222', bn_decay=bn_decay)
new_points_maxpool = tf.reduce_max(l0_points, axis=[1], keep_dims=True, name='maxpooll11111')
#new_points_maxpool = tf.reduce_mean(l0_points, axis=[1], keep_dims=True, name='avgpool1')
new_points_maxpool = tf.tile(new_points_maxpool, [1,l0_points.shape[1],1])
l0_points = tf.concat([l0_points, new_points_maxpool], -1)
"""
"""
##双层 第一层
l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=8192, radius=2, nsample=64, mlp=[16,16,32], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1')
l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=2048, radius=4, nsample=64, mlp=[32,32,64], 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=512, radius=8, nsample=64, mlp=[64,64,128], mlp2=None, group_all=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=128, radius=16, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4')
l5_xyz, l5_points, l5_indices = pointnet_sa_module(l4_xyz, l4_points, npoint=32, radius=32, nsample=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer5')#128
"""
"""
attsss1 = tf_util.conv1d(l0_points, l0_points.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='fssssc1111', bn_decay=bn_decay)
attsss1 = tf_util.conv1d(attsss1, l0_points.shape[-1], 1, padding='VALID', bn=False, is_training=is_training, scope='fcssss2222', bn_decay=bn_decay)
attsss1 = tf.nn.softmax(attsss1)
l0_points = tf.multiply(attsss1, l0_points)
"""
#l0_points = tf.concat([l0_xyz, l0_points], axis=-1)
"""
l0_points = tf.expand_dims(l0_points, 2)
l0_points = tf_util.conv2d(l0_points, 32, [1,1],
padding='VALID', stride=[1,1],
bn=False, is_training=is_training,
scope='convfp1267777', bn_decay=bn_decay)
l0_points = tf.squeeze(l0_points, [2]) # B,ndataset1,mlp[-1]
"""
l01_xyz, l01_points, l01_indices, max_a0, min_a0 = pointnet_sa_module(l0_xyz, l0_points, npoint=8192, radius=2, nsample=64, mlp=[32,32,64], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer0')#8192
l1_xyz, l1_points, l1_indices, max_a1, min_a1 = pointnet_sa_module(l01_xyz, l01_points, npoint=2048, radius=4, nsample=64, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1')#2048
l2_xyz, l2_points, l2_indices, max_a2, min_a2 = pointnet_sa_module(l1_xyz, l1_points, npoint=512, radius=8, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2')#512
l3_xyz, l3_points, l3_indices, max_a3, min_a3 = pointnet_sa_module(l2_xyz, l2_points, npoint=128, radius=16, nsample=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3')#128
l4_xyz, l4_points, l4_indices, max_a4, min_a4 = pointnet_sa_module(l3_xyz, l3_points, npoint=32, radius=32, nsample=64, mlp=[512,512,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4')#radius=32
#l5_xyz, l5_points, l5_indices, max_a5, min_a5 = pointnet_sa_module(l4_xyz, l4_points, npoint=16, radius=64, nsample=64, mlp=[512,512,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer5')#radius=32
#最后一个radius=32 nsample=32 可以达到75% #nsample=64效果也很好
#best
# Feature Propagation layers
"""
l01_xyz, l01_points, l01_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=8192, radius=2, nsample=64, mlp=[32,32,64], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer0')#8192
l1_xyz, l1_points, l1_indices = pointnet_sa_module(l01_xyz, l01_points, npoint=2048, radius=4, nsample=64, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1')#2048
l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=512, radius=8, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2')#512
l3_xyz, l3_points, l3_indices = pointnet_sa_module(l2_xyz, l2_points, npoint=128, radius=16, nsample=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3')#128
l4_xyz, l4_points, l4_indices = pointnet_sa_module(l3_xyz, l3_points, npoint=32, radius=32, nsample=64, mlp=[512,512,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4')#radius=32
l5_xyz, l5_points, l5_indices = pointnet_sa_module(l4_xyz, l4_points, npoint=8, radius=64, nsample=64, mlp=[1024,1024,2048], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer44')#radius=32
"""
"""
l01_xyz, l01_points, l01_indices = pointnet_sa_module(l0_xyz, l0_points, npoint=16384, radius=2, nsample=32, mlp=[16,16,32], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer0')
l1_xyz, l1_points, l1_indices = pointnet_sa_module(l01_xyz, l01_points, npoint=4096, radius=4, nsample=32, mlp=[32,32,64], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1')
l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points, npoint=1024, radius=8, nsample=32, mlp=[64,64,128], 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=256, radius=16, nsample=32, mlp=[128,128,256], mlp2=None, group_all=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=64, radius=32, nsample=32, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4')
l5_xyz, l5_points, l5_indices = pointnet_sa_module(l4_xyz, l4_points, npoint=16, radius=64, nsample=32, mlp=[512,512,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer5')
"""
"""
l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [512,512], is_training, bn_decay, scope='fa_layer1')
l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [512,256], is_training, bn_decay, scope='fa_layer2')
l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [256,256], is_training, bn_decay, scope='fa_layer3')
l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,128], is_training, bn_decay, scope='fa_layer4')
l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_points, [128,128,128], is_training, bn_decay, scope='fa_layer5')
"""
"""
##双层 第一层
l4_fp_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [512,512,256], is_training, bn_decay, scope='fa_layer0')#l4_fp_points
l3_fp_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_fp_points, [256,256,128], is_training, bn_decay, scope='fa_layer1')#l3_fp_points
l2_fp_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_fp_points, [128,128,64], is_training, bn_decay, scope='fa_layer2')#l2_fp_points
l1_fp_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_fp_points, [64,64,32], is_training, bn_decay, scope='fa_layer3')#l1_fp_points
l0_fp_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_fp_points, [32,32,32], is_training, bn_decay, scope='fa_layer4')#l0_fp_points
net1 = tf_util.conv1d(l0_fp_points, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc11', bn_decay=bn_decay)
#net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1')
#net = tf_util.conv1d(net, 2*num_class, 1, padding='VALID', bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
net1 = tf_util.conv1d(net1, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc21', bn_decay=bn_decay)
#net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2')
net1 = tf_util.conv1d(net1, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc31', bn_decay=bn_decay)
##att_net1 = tf_util.conv1d(net1, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc41', bn_decay=bn_decay)
#net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2')
##att_net1 = tf_util.conv1d(att_net1, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc51', bn_decay=bn_decay)
##att_net1 = tf.nn.softmax(att_net1)
##net11 = net1
##net1 = tf_util.dropout(net1, keep_prob=0.5, is_training=is_training, scope='dp31')
#net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc2')
net1 = tf_util.conv1d(net1, num_class, 1, padding='VALID', activation_fn=None, scope='fc41')
"""
"""
##双层 第二层
l1_xyz, l1_points, l1_indices = pointnet_sa_module(l0_xyz, net1, npoint=8192, radius=2, nsample=64, mlp=[16,16,32], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer11')
l1_points1 = tf.concat([l1_points, l1_fp_points], -1)
l2_xyz, l2_points, l2_indices = pointnet_sa_module(l1_xyz, l1_points1, npoint=2048, radius=4, nsample=64, mlp=[32,32,64], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer21')
l2_points1 = tf.concat([l2_points, l2_fp_points], -1)
l3_xyz, l3_points, l3_indices = pointnet_sa_module1(l2_xyz, l2_points1, npoint=512, radius=8, nsample=64, mlp=[64,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer31')
l3_points1 = tf.concat([l3_points, l3_fp_points], -1)
l4_xyz, l4_points, l4_indices = pointnet_sa_module(l3_xyz, l3_points1, npoint=128, radius=16, nsample=64, mlp=[128,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer41')
l4_points1 = tf.concat([l4_points, l4_fp_points], -1)
l5_xyz, l5_points, l5_indices = pointnet_sa_module(l4_xyz, l4_points1, npoint=32, radius=32, nsample=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer51')
l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points1, l5_points, [512,512,256], is_training, bn_decay, scope='fa_layer01')
l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points1, l4_points, [256,256,128], is_training, bn_decay, scope='fa_layer11')
l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points1, l3_points, [128,128,64], is_training, bn_decay, scope='fa_layer21')
l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points1, l2_points, [64,64,32], is_training, bn_decay, scope='fa_layer31')
l0_points = pointnet_fp_module(l0_xyz, l1_xyz, net1, l1_points, [32,32,32], is_training, bn_decay, scope='fa_layer41')
"""
#l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [1024,1024,512], is_training, bn_decay, radius=16, scope='fa_layer01')
l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [1024,1024,512], is_training, bn_decay, radius=8, scope='fa_layer0')
l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512,512,256], is_training, bn_decay, radius=4, scope='fa_layer1')
l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,256,128], is_training, bn_decay, radius=2, scope='fa_layer2')
l01_points = pointnet_fp_module(l01_xyz, l1_xyz, l01_points, l1_points, [128,128,64], is_training, bn_decay, radius=1, scope='fa_layer3')
l0_points = pointnet_fp_module(l0_xyz, l01_xyz, l0_points, l01_points, [64,64,64], is_training, bn_decay, radius=0.5, scope='fa_layer4')
l0_points = pointnet_fp_module144(l0_xyz, l0_xyz, l0_points, l0_points, [64,64,64], is_training, bn_decay, radius=1, scope='fa_layer5')
#best
"""
l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [2048,2048,1024], is_training, bn_decay, scope='fa_layer00')
l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [1024,1024,512], is_training, bn_decay, scope='fa_layer0')
l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512,512,256], is_training, bn_decay, scope='fa_layer1')
l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,256,128], is_training, bn_decay, scope='fa_layer2')
l01_points = pointnet_fp_module(l01_xyz, l1_xyz, l01_points, l1_points, [128,128,64], is_training, bn_decay, scope='fa_layer3')
l0_points = pointnet_fp_module(l0_xyz, l01_xyz, l0_points, l01_points, [64,32,32], is_training, bn_decay, scope='fa_layer4')
"""
"""
l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [512,512], is_training, bn_decay, scope='fa_layer0')
l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [512,256], is_training, bn_decay, scope='fa_layer1')
l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [256,256], is_training, bn_decay, scope='fa_layer2')
l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,256], is_training, bn_decay, scope='fa_layer3')
l01_points = pointnet_fp_module(l01_xyz, l1_xyz, l01_points, l1_points, [256,128], is_training, bn_decay, scope='fa_layer4')
l0_points = pointnet_fp_module(l0_xyz, l01_xyz, l0_points, l01_points, [128,128,128], is_training, bn_decay, scope='fa_layer5')
"""
"""
##l0_points = l0_fp_points * 0.8 + l0_points
##l0_points = tf.concat([l0_fp_points, l0_points], -1)
##l0_points = tf.multiply(l0_fp_points, l0_points)
# FC layers
net = tf_util.conv1d(l0_points, 32, 1, padding='VALID', 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.conv1d(net, 2*num_class, 1, padding='VALID', bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
net = tf_util.conv1d(net, 32, 1, padding='VALID', 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.conv1d(net, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc3', bn_decay=bn_decay)
#net = tf.concat([net, net1], -1)
#att_net = tf_util.conv1d(net, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc14', bn_decay=bn_decay)
#net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp2')
#att_net = tf_util.conv1d(att_net, 32, 1, padding='VALID', bn=True, is_training=is_training, scope='fc15', bn_decay=bn_decay)
#att_net = tf.nn.softmax(att_net)
#end_points['feats'] = net
##end_points['feats'] = net1 * att_net + net * att_net1
##net = net1 * att_net + net * att_net1
#net = tf.add(tf.multiply(net1, att_net), tf.multiply(net, att_net1))
#net = tf.add(tf.multiply(net1, 0.6), net)
######net = net1 * 0.8 + net
######end_points['feats'] = net
#net = tf.multiply(net, net1)
###net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp3')
#net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc2')
net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc4')
"""
net = tf_util.conv1d(l0_points, 64, 1, padding='VALID', bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay)
net = tf_util.conv1d(net, 64, 1, padding='VALID', bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
net = tf_util.conv1d(net, 64, 1, padding='VALID', bn=True, is_training=is_training, scope='fc3', bn_decay=bn_decay)
net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp3')
net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc7')
########return net, net1, end_points
return net, end_points, max_a0, min_a0
def get_loss(pred, label, smpw):
""" pred: BxNxC,
label: BxN,
smpw: BxN """
classify_loss = tf.losses.sparse_softmax_cross_entropy(labels=label, logits=pred, weights=smpw)
tf.summary.scalar('classify loss', classify_loss)
tf.add_to_collection('losses', classify_loss)
return classify_loss
if __name__=='__main__':
with tf.Graph().as_default():
inputs = tf.zeros((32,2048,3))
net, _ = get_model(inputs, tf.constant(True), 10)
print(net)