From 9de22673df67b5a27d8e9fc780329a016fe4ccc0 Mon Sep 17 00:00:00 2001 From: weishengyu Date: Fri, 8 Apr 2022 14:29:03 +0800 Subject: [PATCH] dbg --- ppcls/arch/gears/bnneck.py | 4 ++-- ppcls/arch/gears/fc.py | 4 ++-- ppcls/configs/Pedestrian/strong_baseline_m1.yaml | 8 ++++---- ppcls/engine/evaluation/retrieval.py | 2 +- ppcls/loss/triplet.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ppcls/arch/gears/bnneck.py b/ppcls/arch/gears/bnneck.py index 9cd051ab..2a63ebe6 100644 --- a/ppcls/arch/gears/bnneck.py +++ b/ppcls/arch/gears/bnneck.py @@ -8,8 +8,8 @@ class BNNeck(paddle.nn.Layer): self.bn = paddle.nn.BatchNorm1D( self.num_filters) - if not trainable: - self.bn.bias.trainable = False + # if not trainable: + # self.bn.bias.trainable = False def forward(self, input, label=None): out = self.bn(input) diff --git a/ppcls/arch/gears/fc.py b/ppcls/arch/gears/fc.py index b3247419..9ad0ed8e 100644 --- a/ppcls/arch/gears/fc.py +++ b/ppcls/arch/gears/fc.py @@ -21,14 +21,14 @@ import paddle.nn as nn class FC(nn.Layer): - def __init__(self, embedding_size, class_num): + def __init__(self, embedding_size, class_num, bias_attr=None): super(FC, self).__init__() self.embedding_size = embedding_size self.class_num = class_num weight_attr = paddle.ParamAttr( initializer=paddle.nn.initializer.XavierNormal()) self.fc = paddle.nn.Linear( - self.embedding_size, self.class_num, weight_attr=weight_attr) + self.embedding_size, self.class_num, weight_attr=weight_attr, bias_attr=bias_attr) def forward(self, input, label=None): out = self.fc(input) diff --git a/ppcls/configs/Pedestrian/strong_baseline_m1.yaml b/ppcls/configs/Pedestrian/strong_baseline_m1.yaml index 7edb9349..6ec16b0e 100644 --- a/ppcls/configs/Pedestrian/strong_baseline_m1.yaml +++ b/ppcls/configs/Pedestrian/strong_baseline_m1.yaml @@ -26,14 +26,14 @@ Arch: stem_act: null BackboneStopLayer: name: "flatten" - #Neck: - # name: BNNeck - # num_filters: 2048 - # trainable: false + Neck: + name: BNNeck + num_filters: 2048 Head: name: "FC" embedding_size: 2048 class_num: 751 + bias_attr: false # loss function config for traing/eval process Loss: diff --git a/ppcls/engine/evaluation/retrieval.py b/ppcls/engine/evaluation/retrieval.py index 8471a42c..45b6c41e 100644 --- a/ppcls/engine/evaluation/retrieval.py +++ b/ppcls/engine/evaluation/retrieval.py @@ -125,7 +125,7 @@ def cal_feature(engine, name='gallery'): out = engine.model(batch[0], batch[1]) if "Student" in out: out = out["Student"] - batch_feas = out["features"] + batch_feas = out["backbone"] # do norm if engine.config["Global"].get("feature_normalize", True): diff --git a/ppcls/loss/triplet.py b/ppcls/loss/triplet.py index d1c7eec9..5df48b0d 100644 --- a/ppcls/loss/triplet.py +++ b/ppcls/loss/triplet.py @@ -24,7 +24,7 @@ class TripletLossV2(nn.Layer): inputs: feature matrix with shape (batch_size, feat_dim) target: ground truth labels with shape (num_classes) """ - inputs = input["features"] + inputs = input["backbone"] if self.normalize_feature: inputs = 1. * inputs / (paddle.expand_as( -- GitLab