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

Method _create_model

modelzoo/bst/train.py:237–328  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

235
236 # create model
237 def _create_model(self):
238 # input embeddings of user & item features
239 for key in TAG_COLUMN:
240 self._feature[key] = tf.strings.split(self._feature[key], '|')
241 self._feature[key] = tf.sparse.slice(
242 self._feature[key], [0, 0],
243 [self._batch_size, self._max_seqence_length - 1])
244 # input layer
245 with tf.variable_scope('input_layer',
246 partitioner=self._input_layer_partitioner):
247 # unsequence input
248 key_dict = {}
249 with tf.variable_scope('unseq_input_layer', reuse=tf.AUTO_REUSE):
250 if self._adaptive_emb and not self.tf:
251 '''Adaptive Embedding Feature Part 1 of 2'''
252 adaptive_mask_tensors = {}
253 for col in INPUT_FEATURES:
254 adaptive_mask_tensors[col] = tf.ones([args.batch_size],
255 tf.int32)
256 unseq_emb = tf.feature_column.input_layer(
257 self._feature,
258 self._unseq_column,
259 adaptive_mask_tensors=adaptive_mask_tensors,
260 cols_to_output_tensors=key_dict)
261 else:
262 unseq_emb = tf.feature_column.input_layer(
263 self._feature,
264 self._unseq_column,
265 cols_to_output_tensors=key_dict)
266
267 # bst input
268 with tf.variable_scope('bst_input_layer', reuse=tf.AUTO_REUSE):
269 # tag input
270 with tf.variable_scope('tag_input_layer', reuse=tf.AUTO_REUSE):
271 tag_emb, tag_len = tf.contrib.feature_column.sequence_input_layer(
272 self._feature, self._tag_column)
273
274 # key input
275 with tf.variable_scope('key_input_layer', reuse=tf.AUTO_REUSE):
276 key_emb_list = []
277 for key in self._key_column:
278 key_emb_list.append(key_dict[key])
279 key_emb = tf.concat(key_emb_list, axis=-1)
280
281 if self.bf16:
282 unseq_emb = tf.cast(unseq_emb, dtype=tf.bfloat16)
283 tag_emb = tf.cast(tag_emb, dtype=tf.bfloat16)
284 key_emb = tf.cast(key_emb, dtype=tf.bfloat16)
285
286 bst_tower_fea = {
287 'key': key_emb,
288 'hist_seq_emb': tag_emb,
289 'hist_seq_len': tag_len
290 }
291
292 # BST
293 bst_scope = tf.variable_scope(
294 'bst_tower',

Callers 1

__init__Method · 0.95

Calls 9

_bst_towerMethod · 0.95
sliceMethod · 0.80
variable_scopeMethod · 0.80
onesMethod · 0.80
keep_weightsMethod · 0.80
splitMethod · 0.45
appendMethod · 0.45
concatMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected