diff --git a/ppcls/arch/gears/bnneck.py b/ppcls/arch/gears/bnneck.py index 9cd051ab6292d34da7a2b2d3c3107cb514b980ec..2a63ebe6e5df38bba66bc49d5e6687ec94752d1a 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 b32474195e1ada4cd0a17b493f68f65a242d82cd..9ad0ed8ef664774378a49f361a98d1ae73977e00 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 7edb9349b6760d67dece7446f46aa0aff9694526..6ec16b0ed0bbf2ea33560ad08d495f3ba0c5326e 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 8471a42c7421648b75a56e426bf3e1ab9c14a5fd..45b6c41eb7546a81c4c1449fae3dcecaf56b33af 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 d1c7eec9e6031aa7e51a1a3575094e7d1a4f90df..5df48b0d373e077cbb714a0d00a868e30b517fd7 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(