We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
bs is not defined and should probably be batch_size
bs
batch_size
def train(model, input_data, target_data, batch_size=500, iterations=5): criterion = MSELoss() optim = SGD(parameters=model.get_parameters(), alpha=0.01) n_batches = int(len(input_data) / batch_size) for iter in range(iterations): iter_loss = 0 for b_i in range(n_batches): # padding token should stay at 0 model.weight.data[w2i['<unk>']] *= 0 input = Tensor(input_data[b_i*bs:(b_i+1)*bs], autograd=True) target = Tensor(target_data[b_i*bs:(b_i+1)*bs], autograd=True) pred = model.forward(input).sum(1).sigmoid() loss = criterion.forward(pred,target) loss.backward() optim.step() iter_loss += loss.data[0] / bs sys.stdout.write("\r\tLoss:" + str(iter_loss / (b_i+1))) print() return model
The text was updated successfully, but these errors were encountered:
I guess the same and it works if change bs to the batch_size
Sorry, something went wrong.
Created pr here : #44
No branches or pull requests
bs
is not defined and should probably bebatch_size
The text was updated successfully, but these errors were encountered: