Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge fa12e6a into e53f60b
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Sep 20, 2019
2 parents e53f60b + fa12e6a commit bc8f72e
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions deeprank/learn/NeuralNet.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,18 @@ def _train(self, index_train, index_valid, index_test,
logger.info(f'\n: epoch {epoch:03d} / {nepoch:03d} {"-"*45}')
t0 = time.time()

# train the model
logger.info(f"\n\t=> train the model\n")
train_loss, self.data['train'] = self._epoch(
train_loader, train_model=True)
self.losses['train'].append(train_loss)
if self.save_classmetrics:
for i in self.metricnames:
self.classmetrics[i]['train'].append(self.data['train'][i])

# validate the model
if _valid_:

sys.stdout.flush()
logger.info(f"\n\t=> validate the model\n")

valid_loss, self.data['valid'] = self._epoch(
valid_loader, train_model=False)
self.losses['valid'].append(valid_loss)
Expand All @@ -655,9 +661,7 @@ def _train(self, index_train, index_valid, index_test,

# test the model
if _test_:
sys.stdout.flush()
logger.info(f"\n\t=> test the model\n")

test_loss, self.data['test'] = self._epoch(
test_loader, train_model=False)
self.losses['test'].append(test_loss)
Expand All @@ -666,16 +670,6 @@ def _train(self, index_train, index_valid, index_test,
self.classmetrics[i]['test'].append(
self.data['test'][i])

# train the model
sys.stdout.flush()
logger.info(f"\n\t=> train the model\n")
train_loss, self.data['train'] = self._epoch(
train_loader, train_model=True)
self.losses['train'].append(train_loss)
if self.save_classmetrics:
for i in self.metricnames:
self.classmetrics[i]['train'].append(self.data['train'][i])

# talk a bit about losse
logger.info(f'\n train loss : {train_loss:1.3e}')
if _valid_:
Expand Down

0 comments on commit bc8f72e

Please sign in to comment.