-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hhh #3
Comments
`#coding:utf-8 xyzvalues = np.random.choice(range(2,100), size=(10,10,10))xyzvalues = np.zeros((10,10,20)) xyzvalues[0,0:,0] = 0.1 xyzminvalue=xyzvalues.min() relativevalue=np.zeros((10,10,20)) for i in range(0,relativevalue.shape[0]): colorsvalues = np.empty(xyzvalues.shape, dtype=object) for i in range(0,relativevalue.shape[0]):
#tuple为不可变数据类型,所以替换自定义alpha值时需要重新定义
#最终每个数值所对应的颜色 fig = plt.figure(figsize=(7, 4.5)) Make a figure and axes with dimensions as desired.#需要注意的是,3Dplot不支持设置xyz的比例尺相同,这就带来了一些麻烦: ax = fig.gca(projection='3d') #ax.voxels(xyzvalues, facecolors=colorsvalues, edgecolor='k',shade=False,) ax.set_xlabel('X');ax.set_ylabel('Y');ax.set_zlabel('Z')ax.set_title('3D Voxel Map')#新建区域ax1,用以额外绘制colorbar #获得绘制的句柄ax1 = fig.add_axes([left, bottom, width, height])# Set the colormap and norm to correspond to the data for which# the colorbar will be used.cmap = mpl.cm.plasma#colormap与绘制voxel图保持一致norm = mpl.colors.Normalize(vmin=xyzminvalue, vmax=xyzmaxvalue)#色温colorbar的数值范围可选择实际xyz数组中的数值范围(其实不应该从0开始)cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap,norm=norm,orientation='vertical')cb1.set_label('Units')plt.axis('off') |
`def conv_down(inp,oup):
return nn.Sequential(
nn.Conv2d(inp,oup,4,stride=2,padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(oup,oup,3,stride=1,padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True)
)
def conv_up(inp,oup):
return nn.Sequential(
nn.ConvTranspose2d(inp,oup,2,stride=2,padding=0),
nn.LeakyReLU(negative_slope=0.2, inplace=True)
)
def conv_merge(inp,oup):
return nn.Sequential(
nn.Conv2d(inp, oup, 1, stride=1, padding=0),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(oup, oup, 3, stride=1, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(oup, oup, 3, stride=1, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True)
)
def conv(inp,oup):
return nn.Sequential(
nn.Conv2d(inp, oup, 3, stride=1, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
)
def convbn(in_channel, out_channel, kernel_size, stride, pad, dilation):
#no bn
return nn.Sequential(
nn.Conv2d(
in_channel,
out_channel,
kernel_size=kernel_size,
stride=stride,
padding=dilation if dilation > 1 else pad,
dilation=dilation))
class BasicBlock(nn.Module):
"""ResNet BasicBlock"""
expansion = 1
class Unet(nn.Module):
def init(self):
super().init()
#16,16,24,24,32
self.conv1 = conv(3, 16)
self.down1 = conv_down(16,16)
self.down2 = conv_down(16,24)
self.down3 = conv_down(24,24)
self.down4 = nn.Sequential(conv_down(24,32),
nn.Conv2d(32, 32, 3, stride=1, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(32, 32, 3, stride=1, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True)
)
class Initial(nn.Module):
#share the 4*4 conv
def init(self,inp,maxdisp=256,scale=8):
super().init()
self.maxdisp = maxdisp
self.scale = scale
# self.pad = torch.nn.ZeroPad2d(padding=(0, 3, 0, 0))
self.pad = torch.nn.ZeroPad2d(padding=(1, 2, 0, 0))
self.conv4_4 = nn.Conv2d(inp,16,4,stride=4)
self.conv4_4.weight = nn.Parameter(torch.randn(16,inp,4,4).cuda())
self.conv4_4.bias = nn.Parameter(torch.randn(16).cuda())
self.post = nn.Sequential(
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(16,16,1,stride=1,padding=0),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
)
The text was updated successfully, but these errors were encountered: