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

Function get_embedding_variable

tensorflow/python/ops/variable_scope.py:2147–2210  ·  view source on GitHub ↗
(name,
                           embedding_dim,
                           key_dtype=dtypes.int64,
                           value_dtype=None,
                           initializer=None,
                           regularizer=None,
                           trainable=True,
                           collections=None,
                           caching_device=None,
                           partitioner=None,
                           validate_shape=True,
                           custom_getter=None,
                           constraint=None,
                           steps_to_live=None,
                           init_data_source=None,
                           ev_option = variables.EmbeddingVariableOption())

Source from the content-addressed store, hash-verified

2145
2146@tf_export(v1=["get_embedding_variable"])
2147def get_embedding_variable(name,
2148 embedding_dim,
2149 key_dtype=dtypes.int64,
2150 value_dtype=None,
2151 initializer=None,
2152 regularizer=None,
2153 trainable=True,
2154 collections=None,
2155 caching_device=None,
2156 partitioner=None,
2157 validate_shape=True,
2158 custom_getter=None,
2159 constraint=None,
2160 steps_to_live=None,
2161 init_data_source=None,
2162 ev_option = variables.EmbeddingVariableOption()):
2163 if key_dtype == dtypes.int64:
2164 invalid_key = 9223372036854775807
2165 elif key_dtype == dtypes.int32:
2166 invalid_key = -1
2167 elif key_dtype == dtypes.string:
2168 invalid_key = ""
2169 else:
2170 raise ValueError("Not support key_dtype: %s, only support int64/int32/string" % key_dtype)
2171 l2_weight_threshold = -1.0
2172 if initializer is None and ev_option.init.initializer is None:
2173 initializer = init_ops.truncated_normal_initializer()
2174 elif ev_option.init.initializer is not None:
2175 if initializer is not None:
2176 print("use initializer give in InitializerOption.")
2177 initializer = ev_option.init.initializer
2178 if steps_to_live != None:
2179 logging.warn("steps_to_live is deprecated,"
2180 " use tf.GlobaStepEvcit(steps_to_live)")
2181 if ev_option.evict != None:
2182 if isinstance(ev_option.evict, variables.GlobalStepEvict):
2183 if steps_to_live != None:
2184 logging.warning("Warning: steps_to_live is double set, the steps_to_live in GlobalStepEvict is valid")
2185 steps_to_live = ev_option.evict.steps_to_live
2186 elif isinstance(ev_option.evict, variables.L2WeightEvict):
2187 l2_weight_threshold = ev_option.evict.l2_weight_threshold
2188 else:
2189 l2_weight_threshold = -1.0
2190 if steps_to_live != None and l2_weight_threshold > 0:
2191 raise ValueError("step_to_live and l2_weight_threshold can't be enabled at same time.")
2192 return get_variable_scope().get_embedding_variable(
2193 _get_default_variable_store(), name, shape=embedding_dim, dtype=value_dtype,
2194 initializer=initializer, regularizer=regularizer, trainable=trainable,
2195 collections=collections, caching_device=caching_device,
2196 partitioner=partitioner, validate_shape=validate_shape,
2197 use_resource=True, custom_getter=custom_getter,
2198 constraint=constraint, invalid_key=invalid_key,
2199 evconfig=variables.EmbeddingVariableConfig(
2200 steps_to_live=steps_to_live,init_data_source=init_data_source,ht_type=ev_option.ht_type,
2201 l2_weight_threshold=l2_weight_threshold,
2202 filter_strategy=ev_option.filter_strategy,
2203 storage_type = ev_option.storage_option.storage_type,
2204 storage_path = ev_option.storage_option.storage_path,

Callers

nothing calls this directly

Calls 3

get_variable_scopeFunction · 0.85

Tested by

no test coverage detected