MCPcopy Create free account
hub / github.com/apache/singa / cossim

Function cossim

python/singa/autograd.py:5005–5017  ·  view source on GitHub ↗

Produces a cos similarity operator Args: a (CTensor): input tensor. b (CTensor): input tensor. Returns: the output Tensor.

(a, b)

Source from the content-addressed store, hash-verified

5003
5004
5005def cossim(a, b):
5006 """
5007 Produces a cos similarity operator
5008 Args:
5009 a (CTensor): input tensor.
5010 b (CTensor): input tensor.
5011 Returns:
5012 the output Tensor.
5013 """
5014 assert a.shape == b.shape, "shape not match for cossim"
5015 assert a.ndim() == 2, "shape should be in 2d for cossim"
5016 assert b.ndim() == 2, "shape should be in 2d for cossim"
5017 return CosSim()(a, b)[0]
5018
5019
5020class Expand(Operator):

Callers

nothing calls this directly

Calls 2

CosSimClass · 0.85
ndimMethod · 0.45

Tested by

no test coverage detected