Comments (5)
Did you use this code?
import torch
import torch.nn as nn
from conformer import Conformer
batch_size, sequence_length, dim = 3, 12345, 80
cuda = torch.cuda.is_available()
device = torch.device('cuda' if cuda else 'cpu')
inputs = torch.rand(batch_size, sequence_length, dim).to(device)
input_lengths = torch.IntTensor([12345, 12300, 12000])
targets = torch.LongTensor([[1, 3, 3, 3, 3, 3, 4, 5, 6, 2],
[1, 3, 3, 3, 3, 3, 4, 5, 2, 0],
[1, 3, 3, 3, 3, 3, 4, 2, 0, 0]]).to(device)
target_lengths = torch.LongTensor([9, 8, 7])
model = nn.DataParallel(Conformer(num_classes=10, input_dim=dim,
encoder_dim=32, num_encoder_layers=3,
decoder_dim=32)).to(device)
# Forward propagate
outputs = model(inputs, input_lengths, targets, target_lengths)
# Recognize input speech
outputs = model.module.recognize(inputs, input_lengths)
from conformer.
Did you use this code?
import torch import torch.nn as nn from conformer import Conformer batch_size, sequence_length, dim = 3, 12345, 80 cuda = torch.cuda.is_available() device = torch.device('cuda' if cuda else 'cpu') inputs = torch.rand(batch_size, sequence_length, dim).to(device) input_lengths = torch.IntTensor([12345, 12300, 12000]) targets = torch.LongTensor([[1, 3, 3, 3, 3, 3, 4, 5, 6, 2], [1, 3, 3, 3, 3, 3, 4, 5, 2, 0], [1, 3, 3, 3, 3, 3, 4, 2, 0, 0]]).to(device) target_lengths = torch.LongTensor([9, 8, 7]) model = nn.DataParallel(Conformer(num_classes=10, input_dim=dim, encoder_dim=32, num_encoder_layers=3, decoder_dim=32)).to(device) # Forward propagate outputs = model(inputs, input_lengths, targets, target_lengths) # Recognize input speech outputs = model.module.recognize(inputs, input_lengths)
Yes.
Traceback (most recent call last):
File "test_model.py", line 22, in
outputs = model(inputs, input_lengths, targets, target_lengths)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 577, in call
result = self.forward(*input, **kwargs)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 156, in forward
return self.gather(outputs, self.output_device)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 168, in gather
return gather(outputs, output_device, dim=self.dim)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 68, in gather
res = gather_map(outputs)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 55, in gather_map
return Gather.apply(target_device, dim, *outputs)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 68, in forward
return comm.gather(inputs, ctx.dim, ctx.target_device)
File "/opt/conda/lib/python3.6/site-packages/torch/cuda/comm.py", line 165, in gather
return torch._C._gather(tensors, dim, destination)
RuntimeError: Gather got an input of invalid size: got [1, 3085, 8, 10], but expected [1, 3085, 9, 10]
from conformer.
Do you want to try it without nn.DataParallel?
from conformer.
Do you want to try it without nn.DataParallel?
thx! OK now.
import torch
import torch.nn as nn
from conformer import Conformer
batch_size, sequence_length, dim = 3, 12345, 80
cuda = torch.cuda.is_available()
device = torch.cuda.set_device('cuda:0')
inputs = torch.rand(batch_size, sequence_length, dim).to(device)
input_lengths = torch.IntTensor([12345, 12300, 12000])
targets = torch.LongTensor([[1, 3, 3, 3, 3, 3, 4, 5, 6, 2],
[1, 3, 3, 3, 3, 3, 4, 5, 2, 0],
[1, 3, 3, 3, 3, 3, 4, 2, 0, 0]]).to(device)
target_lengths = torch.LongTensor([9, 8, 7])
model = Conformer(num_classes=10, input_dim=dim,
encoder_dim=32, num_encoder_layers=3,
decoder_dim=32).to(device)
Forward propagate
outputs = model(inputs, input_lengths, targets, target_lengths)
Recognize input speech
outputs = model.recognize(inputs, input_lengths)
print(outputs)
from conformer.
I'm operating normally. It's weird.
from conformer.
Related Issues (20)
- There is a problem about training a conformer+RNN-T model? HOT 6
- When using Conformer in speech recognition HOT 1
- export onnx HOT 1
- mat1 and mat2 shapes cannot be multiplied (1323x9248 and 1568x32) HOT 2
- Influence of 10ms to 40ms rate in Conformer HOT 1
- Forward function missing to FC layer
- Outputs differ from Targets HOT 8
- The meaning of Usage HOT 1
- no mask ? HOT 1
- The model has two outputs. What do they mean? HOT 1
- Feature Extraction using Pre-trained Conformer Model
- to use conformer for acoustic scenes classification ? HOT 1
- NaN output and loss value
- 您好,您有这篇论文”[时域语音增强] SE-Conformer: Time-Domain Speech Enhancement using Conformer阅读笔记“的代码吗? HOT 1
- Invalid version in setup.py HOT 1
- Testing conformer at realtime
- what does the Class Conv2dSubampling‘s return mean? HOT 2
- Example in README doesn't work
- Request for Implementation of Memory-Efficient Attention in Conformer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conformer.