MCPcopy Create free account
hub / github.com/apple/ml-pointersect / get_embedding_function

Function get_embedding_function

pointersect/models/model_utils.py:253–276  ·  view source on GitHub ↗

r""" Returns a lambda function that internally calls positional_encoding. Args: num_encoding_functions: Number of encoding functions used to compute a positional encoding (default: 6). include_input: Whether to include the input in the positional enco

(
        num_encoding_functions: int = 6,
        include_input: bool = True,
        log_sampling: bool = True,
)

Source from the content-addressed store, hash-verified

251
252
253def get_embedding_function(
254 num_encoding_functions: int = 6,
255 include_input: bool = True,
256 log_sampling: bool = True,
257):
258 r"""
259 Returns a lambda function that internally calls positional_encoding.
260
261 Args:
262 num_encoding_functions:
263 Number of encoding functions used to compute a positional encoding (default: 6).
264 include_input:
265 Whether to include the input in the positional encoding (default: True).
266 log_sampling:
267 whether to sample the sinusoid frequencies in log scale.
268
269 Returns:
270 A lambda function that convert input to positional encoding.
271 the output dimension is (*, dim_out), where
272 :math:`dim_{out} = d_{in} * include_input + num_encoding_functions * 2`
273 """
274 return lambda x: positional_encoding(
275 x, num_encoding_functions, include_input, log_sampling
276 )

Callers

nothing calls this directly

Calls 1

positional_encodingFunction · 0.85

Tested by

no test coverage detected