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

Method _create_model

modelzoo/dbmtl/train.py:148–245  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

146 return tf.variable_scope(name, partitioner=part, reuse=tf.AUTO_REUSE)
147
148 def _create_model(self):
149 TAG_COLUMN = ['tag_category_list', 'tag_brand_list']
150 for key in TAG_COLUMN:
151 self._feature[key] = tf.strings.split(self._feature[key], '|')
152
153 with tf.variable_scope('dnn'):
154 # dnn part
155 key_dict={}
156 with tf.variable_scope('input_layer',
157 partitioner=self._input_layer_partitioner,
158 reuse=tf.AUTO_REUSE):
159 print('Adaptive emb = ', self._adaptive_emb, 'TF = ', self.tf)
160 if self._adaptive_emb and not self.tf:
161 '''Adaptive Embedding Feature part 1 of 2'''
162 print('Adaptive Embedding Feature part 1 of 2')
163 adaptive_mask_tensors = {}
164 for col in HASH_INPUTS:
165 adaptive_mask_tensors[col] = tf.ones([args.batch_size],
166 tf.int32)
167 input_emb = tf.feature_column.input_layer(
168 self._feature,
169 self._feature_column,
170 adaptive_mask_tensors=adaptive_mask_tensors,
171 cols_to_output_tensors=key_dict)
172 else:
173 input_emb = tf.feature_column.input_layer(
174 self._feature,
175 self._feature_column,
176 cols_to_output_tensors=key_dict)
177
178 # Shared Layer
179 with tf.variable_scope('bottom_dnn_'):
180 shared_features = input_emb
181 if self.bf16:
182 shared_features = tf.cast(shared_features, dtype=tf.bfloat16)
183
184 for layer_id, num_hidden_units in enumerate(self._bottom_dnn):
185 with self._make_scope(f'bottom_dnn_layer_{layer_id}', self.bf16, self._dense_layer_partitioner) as shared_layer_scope:
186 shared_features = tf.layers.dense(shared_features,
187 units=num_hidden_units,
188 activation=None,
189 name=f'{shared_layer_scope.name}/dense')
190 shared_features = DNN_ACTIVATION(shared_features, shared_layer_scope.name)
191 self._add_layer_summary(shared_features, shared_layer_scope.name)
192
193 # Specific Layer
194 final_tower = []
195 relations_outputs = {}
196 for [tower_name, label_name, hidden_units] in self._towers:
197 with tf.variable_scope(tower_name):
198 tower_input = shared_features
199
200 specific_features = tower_input
201
202 if self.bf16:
203 specific_features = tf.cast(specific_features, dtype=tf.bfloat16)
204
205 for layer_id, num_hidden_units in enumerate(hidden_units):

Callers 1

__init__Method · 0.95

Calls 9

_make_scopeMethod · 0.95
_add_layer_summaryMethod · 0.95
variable_scopeMethod · 0.80
onesMethod · 0.80
splitMethod · 0.45
castMethod · 0.45
appendMethod · 0.45
concatMethod · 0.45
stackMethod · 0.45

Tested by

no test coverage detected