MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / get_multihash_variable

Function get_multihash_variable

tensorflow/python/ops/variable_scope.py:2317–2369  ·  view source on GitHub ↗
(name,
                           dims,
                           complementary_strategy="Q-R",
                           operation="add",
                           dtype=float,
                           initializer=None,
                           regularizer=None,
                           trainable=None,
                           collections=None,
                           caching_device=None,
                           partitioner=None,
                           validate_shape=True,
                           use_resource = None,
                           custom_getter=None,
                           constraint=None,
                           synchronization=VariableSynchronization.AUTO,
                           aggregation=VariableAggregation.NONE)

Source from the content-addressed store, hash-verified

2315
2316@tf_export(v1=["get_multihash_variable"])
2317def get_multihash_variable(name,
2318 dims,
2319 complementary_strategy="Q-R",
2320 operation="add",
2321 dtype=float,
2322 initializer=None,
2323 regularizer=None,
2324 trainable=None,
2325 collections=None,
2326 caching_device=None,
2327 partitioner=None,
2328 validate_shape=True,
2329 use_resource = None,
2330 custom_getter=None,
2331 constraint=None,
2332 synchronization=VariableSynchronization.AUTO,
2333 aggregation=VariableAggregation.NONE):
2334 strategy_list = ["Q-R"]
2335 op_list = ["add", "mul", "concat"]
2336 num_of_partitions = len(dims)
2337 if complementary_strategy not in strategy_list:
2338 raise ValueError("The strategy %s is not supported" % complementary_strategy)
2339 if operation not in op_list:
2340 raise ValueError("The operation %s is not supported" % operation)
2341 if initializer is None:
2342 initializer = init_ops.truncated_normal_initializer()
2343 if complementary_strategy == 'Q-R':
2344 if num_of_partitions != 2:
2345 raise ValueError("the num_of_partitions must be 2 when using Q-R strategy.")
2346 val_Q = get_variable_scope().get_variable(
2347 _get_default_variable_store(), name +'/multhash_Q',
2348 shape=dims[0], dtype=dtype,
2349 initializer=initializer, regularizer=regularizer, trainable=trainable,
2350 collections=collections, caching_device=caching_device,
2351 partitioner=partitioner, validate_shape=validate_shape,
2352 use_resource=use_resource, custom_getter=custom_getter,
2353 constraint=constraint,synchronization=synchronization,
2354 aggregation=aggregation)
2355 val_R = get_variable_scope().get_variable(
2356 _get_default_variable_store(), name +'/multhash_R',
2357 shape=dims[1], dtype=dtype,
2358 initializer=initializer, regularizer=regularizer, trainable=trainable,
2359 collections=collections, caching_device=caching_device,
2360 partitioner=partitioner, validate_shape=validate_shape,
2361 use_resource=use_resource, custom_getter=custom_getter,
2362 constraint=constraint,synchronization=synchronization,
2363 aggregation=aggregation)
2364 mhv = kv_variable_ops.MultiHashVariable(name, [val_Q, val_R],
2365 variables.MultihashOption(num_of_partitions,
2366 complementary_strategy,
2367 operation,
2368 dims))
2369 return mhv
2370
2371
2372@tf_export(v1=["get_dynamic_dimension_embedding_variable"])

Callers

nothing calls this directly

Calls 3

get_variable_scopeFunction · 0.85
get_variableMethod · 0.45

Tested by

no test coverage detected