I am Jin L, graduated in June 2022, now an algorithm engineer
- 🧐 Interested in ML/DL & RecoSys & Graph & NLP.
Take a look at my repositories and let's get in touch!
Implementation of CCNet: Criss-Cross Attention for Semantic Segmentation
你好,请问你训练、验证和测试数据分别大概使用了多少张多大的图片?
`class CC_module(nn.Module):
def init(self,in_dim):
super(CC_module, self).init()
self.query_conv = nn.Conv2d(in_channels=in_dim, out_channels=in_dim//8, kernel_size=1)
self.key_conv = nn.Conv2d(in_channels=in_dim, out_channels=in_dim//8, kernel_size=1)
self.value_conv = nn.Conv2d(in_channels=in_dim, out_channels=in_dim, kernel_size=1)
self.softmax = Softmax(dim=3)
self.INF = INF
self.gamma = nn.Parameter(torch.zeros(1))
def forward(self, x):
m_batchsize, _, height, width = x.size()
proj_query = self.query_conv(x)
proj_query_H = proj_query.permute(0,3,1,2).contiguous().view(m_batchsizewidth,-1,height).permute(0, 2, 1)
proj_query_W = proj_query.permute(0,2,1,3).contiguous().view(m_batchsizeheight,-1,width).permute(0, 2, 1)
proj_key = self.key_conv(x)
proj_key_H = proj_key.permute(0,3,1,2).contiguous().view(m_batchsizewidth,-1,height)
proj_key_W = proj_key.permute(0,2,1,3).contiguous().view(m_batchsizeheight,-1,width)
proj_value = self.value_conv(x)
proj_value_H = proj_value.permute(0,3,1,2).contiguous().view(m_batchsizewidth,-1,height)
proj_value_W = proj_value.permute(0,2,1,3).contiguous().view(m_batchsizeheight,-1,width)
energy_H = (torch.bmm(proj_query_H, proj_key_H)+self.INF(m_batchsize, height, width)).view(m_batchsize,width,height,height).permute(0,2,1,3)
energy_W = torch.bmm(proj_query_W, proj_key_W).view(m_batchsize,height,width,width)
concate = self.softmax(torch.cat([energy_H, energy_W], 3))
att_H = concate[:,:,:,0:height].permute(0,2,1,3).contiguous().view(m_batchsize*width,height,height)
#print(concate)
#print(att_H)
att_W = concate[:,:,:,height:height+width].contiguous().view(m_batchsize*height,width,width)
out_H = torch.bmm(proj_value_H, att_H.permute(0, 2, 1)).view(m_batchsize,width,-1,height).permute(0,2,3,1)
out_W = torch.bmm(proj_value_W, att_W.permute(0, 2, 1)).view(m_batchsize,height,-1,width).permute(0,2,1,3)
#print(out_H.size(),out_W.size())
return self.gamma*(out_H + out_W) + x`
I am very confused with self.gamma = torch.zero(1)
作者您好!
我查看了一些其他人的CC-Attention的实现,大部分似乎都需要通过什么cuda算子,不清楚为什么。 另外,我看了您的CC-attention的实现,觉得深受启发,有两个小问题咨询您:
1. energy_H = (energy_H + self.INF(m_batchsize, height, width)) , 这里为什么要加入 INF?
2. 您每个q, k, v都分成两个h, w部分,想问问这样的实现方法,是否与理论的CC-attention逻辑一致?
不好意思,因为是个初学者,想请教一下,如果直接改多分类为二分类,image和label给的是[0,1]的值,经过model的输出,output的tensor值应该是什么呢 是每个点所对应的label置信度吗 但是我这样训练的网络 tensor是负值
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.