Code Monkey home page Code Monkey logo

deepspeech2's People

Contributors

zachzhang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

deepspeech2's Issues

整体没问题,但是运行不起来,我这里给了个简单的损失函数替代实现,还有GPU运行时model.py 有些小bug

model.py
def forward(self,x):
h0 = Variable(torch.ones(2, x.size()[0], self.h))
if torch.cuda.is_available():
h0 = h0.cuda()
x = seqWise(self.bn , x)
x = self.rnn(x,h0)[0]
x = x[:, :, :self.h] + x[:, :,self.h:]

train.py
if cuda:
model = model.cuda()
print('model.cuda() is over')

criterion = nn.MSELoss()
optimizer = torch.optim.SGD(model.parameters(),lr = 1)
for epoch in range(epochs):
for i in range(num_batches):
X, y, y_sizes = get_batch(df, batch_size=batch_size)
y = [eval(_) for _ in y] #old y:list of str
# print(len(X),len(y),len(y_sizes),y_sizes,(len(y[0]),len(y[1])),type(y[0]),sep ='\n')
X = Variable(torch.from_numpy(np.expand_dims(X,1)), requires_grad=False ).float()

    #自定义 y
    y = [sum(_)/len(_) for _ in y]
    y = np.array(y).mean()
    y = np.array([y])
    y = Variable(torch.from_numpy(y), requires_grad=False).float()/100
    if cuda:
        X = X.cuda()
        y = y.cuda()
    out = model(X)
    out = out.mean()
    print('out',out,'target',y,sep=' ')
    loss = criterion(out, y)
    
    optimizer.zero_grad()
    loss.backward()
    # SGD step
    optimizer.step()

    if cuda:
        torch.cuda.synchronize()
print('--------epoch',epoch,'loss',loss,sep=' ')

print('train is over final')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.