申请试用
HOT
登录
注册
 
08_ DataLoader

08_ DataLoader

Pony2
/
发布于
/
2184
人观看
dataset = DiabetesDataset() train_loader = DataLoader(dataset=dataset, batch_size=32, shuffle=True, num_workers=2) # Training loop for epoch in range(2): for i, data in enumerate(train_loader, 0): # get the inputs inputs, labels = data # wrap them in Variable inputs, labels = Variable(inputs), Variable(labels) # Forward pass: Compute predicted y by passing x to the model y_pred = model(inputs) # Compute and print loss loss = criterion(y_pred, labels) print(epoch, i, loss.data[0]) # Zero gradients, perform a backward pass, and update the weights. optimizer.zero_grad() loss.backward() optimizer.step()
9点赞
3收藏
0下载
相关推荐
确认
3秒后跳转登录页面
去登陆