提交 11e1c767 编写于 作者: C chenguowei01

Merge branch 'dygraph' of github.com:wuyefeilin/PaddleSeg into dygraph

...@@ -183,12 +183,12 @@ def train(model, ...@@ -183,12 +183,12 @@ def train(model,
loss.backward() loss.backward()
optimizer.minimize(loss) optimizer.minimize(loss)
model.clear_gradients() model.clear_gradients()
avg_loss += loss.numpy() avg_loss += loss.numpy()[0]
lr = optimizer.current_step_lr() lr = optimizer.current_step_lr()
if step % log_steps == 0: if step % log_steps == 0:
avg_loss /= log_steps avg_loss /= log_steps
time_step = timer.elapsed_time() / log_steps time_step = timer.elapsed_time() / log_steps
remain_step = (num_epochs - epoch) * steps_per_epoch - step + 1 remain_step = (num_epochs - epoch) * steps_per_epoch - step - 1
logging.info( logging.info(
"[TRAIN] Epoch={}/{}, Step={}/{}, loss={:.4f}, lr={:.6f}, sec/step={:.4f} | ETA {}" "[TRAIN] Epoch={}/{}, Step={}/{}, loss={:.4f}, lr={:.6f}, sec/step={:.4f} | ETA {}"
.format(epoch + 1, num_epochs, step + 1, steps_per_epoch, .format(epoch + 1, num_epochs, step + 1, steps_per_epoch,
......
...@@ -29,6 +29,7 @@ import models ...@@ -29,6 +29,7 @@ import models
import utils.logging as logging import utils.logging as logging
from utils import get_environ_info from utils import get_environ_info
from utils import ConfusionMatrix from utils import ConfusionMatrix
from utils import Timer, calculate_eta
def parse_args(): def parse_args():
...@@ -96,12 +97,14 @@ def evaluate(model, ...@@ -96,12 +97,14 @@ def evaluate(model,
places=places, places=places,
return_list=True, return_list=True,
) )
total_steps = math.ceil(len(eval_dataset) * 1.0 / batch_size) total_steps = len(batch_sampler)
conf_mat = ConfusionMatrix(num_classes, streaming=True) conf_mat = ConfusionMatrix(num_classes, streaming=True)
logging.info( logging.info(
"Start to evaluating(total_samples={}, total_steps={})...".format( "Start to evaluating(total_samples={}, total_steps={})...".format(
len(eval_dataset), total_steps)) len(eval_dataset), total_steps))
timer = Timer()
timer.start()
for step, data in enumerate(loader): for step, data in enumerate(loader):
images = data[0] images = data[0]
labels = data[1].astype('int64') labels = data[1].astype('int64')
...@@ -113,8 +116,13 @@ def evaluate(model, ...@@ -113,8 +116,13 @@ def evaluate(model,
conf_mat.calculate(pred=pred, label=labels, ignore=mask) conf_mat.calculate(pred=pred, label=labels, ignore=mask)
_, iou = conf_mat.mean_iou() _, iou = conf_mat.mean_iou()
logging.info("[EVAL] Epoch={}, Step={}/{}, iou={}".format( time_step = timer.elapsed_time()
epoch_id, step + 1, total_steps, iou)) remain_step = total_steps - step - 1
logging.info(
"[EVAL] Epoch={}, Step={}/{}, iou={}, sec/step={:.4f} | ETA {}".
format(epoch_id, step + 1, total_steps, iou, time_step,
calculate_eta(remain_step, time_step)))
timer.restart()
category_iou, miou = conf_mat.mean_iou() category_iou, miou = conf_mat.mean_iou()
category_acc, macc = conf_mat.accuracy() category_acc, macc = conf_mat.accuracy()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册