未验证 提交 adfd5c4c 编写于 作者: B Bin Lu 提交者: GitHub

Update msmloss.py

上级 b0d3dd9c
...@@ -69,19 +69,4 @@ class MSMLoss(paddle.nn.Layer): ...@@ -69,19 +69,4 @@ class MSMLoss(paddle.nn.Layer):
def _nomalize(self, input): def _nomalize(self, input):
input_norm = paddle.sqrt(paddle.sum(paddle.square(input), axis=1, keepdim=True)) input_norm = paddle.sqrt(paddle.sum(paddle.square(input), axis=1, keepdim=True))
return paddle.divide(input, input_norm) return paddle.divide(input, input_norm)
if __name__ == "__main__":
import numpy as np
metric = MSMLoss(48)
#prepare data
np.random.seed(1)
features = np.random.randn(48, 32)
#print(features)
#do inference
features = paddle.to_tensor(features)
loss = metric(features)
print(loss)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册