Zaktualizuj 'train-sacred.py'
This commit is contained in:
parent
feb020c9a9
commit
ccbcdd3715
@ -84,17 +84,17 @@ def my_main(epochs):
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
optimizer.zero_grad()
|
||||
|
||||
if (epochs%100==0):
|
||||
print(f'epoch:{epochs+1},loss = {loss.item():.4f}')
|
||||
with open ("output.txt",'a+') as f:
|
||||
if (epochs%100==0):
|
||||
f.write(f'epoch:{epochs+1},loss = {loss.item():.4f}')
|
||||
|
||||
with torch.no_grad():
|
||||
y_predicted = model(X_testing)
|
||||
y_predicted_cls = y_predicted.round()
|
||||
acc = y_predicted_cls.eq(y_testing).sum()/float(y_testing.shape[0])
|
||||
print(f'{acc:.4f}')
|
||||
result = open("output",'w+')
|
||||
result.write(f'{y_predicted}')
|
||||
#result = open("output",'w+')
|
||||
#result.write(f'{y_predicted}')
|
||||
|
||||
torch.save(model, "modelS.pkl")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user