hazedt / waveletkernelnet Goto Github PK
View Code? Open in Web Editor NEWThis is the code for WaveletKernelNet.
This is the code for WaveletKernelNet.
这个可以用来提取图片的高低频特征吗
这不是官方代码?
非常感谢你们的代码,我根据论文看了代码,似乎代码有一些不太一致的地方,不知道我的想法对不对。
`def Morlet(p, c):
y = c * torch.exp(-torch.pow(p, 2) / 2) * torch.cos(5 * p)
return y
class Morlet_fast(nn.Module):
def __init__(self, out_channels, kernel_size, in_channels=1):
super(Morlet_fast, self).__init__()
if in_channels != 1:
msg = "MexhConv only support one input channel (here, in_channels = {%i})" % (in_channels)
raise ValueError(msg)
self.out_channels = out_channels
self.kernel_size = kernel_size - 1
if kernel_size % 2 == 0:
self.kernel_size = self.kernel_size + 1
self.a_ = nn.Parameter(torch.linspace(1, 10, out_channels)).view(-1, 1)
self.b_ = nn.Parameter(torch.linspace(0, 10, out_channels)).view(-1, 1)
def forward(self, waveforms):
time_disc_right = torch.linspace(0, (self.kernel_size / 2) - 1,
steps=int((self.kernel_size / 2)))
time_disc_left = torch.linspace(-(self.kernel_size / 2) + 1, -1,
steps=int((self.kernel_size / 2)))
p1 = (time_disc_right.cuda() - self.b_.cuda()) / self.a_.cuda()
p2 = (time_disc_left.cuda() - self.b_.cuda()) / self.a_.cuda()
C = pow(pi, 0.25)
D = C / torc.sqrt(self.a_.cuda())
Morlet_right = Morlet(p1, D)
Morlet_left = Morlet(p2, D)
Morlet_filter = torch.cat([Morlet_left, Morlet_right], dim=1) # 40x1x250
self.filters = (Morlet_filter).view(self.out_channels, 1, self.kernel_size).cuda()
return F.conv1d(waveforms, self.filters, stride=1, padding=1, dilation=1, bias=None, groups=1)
model2 = Morlet_fast(out_channels=50, kernel_size=18).to(device)
model2.eval()
torch.no_grad()
input = torch.rand(20, 1, 1024).to(device)
output2 = model2(input)
print(output2.size())`
拉普拉斯变换代码line42 是不是应该加上()?
p1 = (time_disc.cuda() - self.b_.cuda()) / self.a_.cuda()
这个小波函数是固定的,函数图像也应该是固定的,为啥原文有训练之前和训练之后不一样的对比?哪里有问题吗
For example,
if in_channels != 1:
msg = "MexhConv only support one input channel (here, in_channels = {%i})" % (in_channels)
raise ValueError(msg)
can be
assert in_channels == 1
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.