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

Class DBMTL

modelzoo/dbmtl/train.py:97–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95'''
96
97class DBMTL():
98 def __init__(self,
99 input,
100 feature_column,
101 bottom_dnn,
102 towers,
103 relation_dnn,
104 optimizer_type='adam',
105 learning_rate=0.1,
106 bf16=False,
107 stock_tf=None,
108 adaptive_emb=False,
109 input_layer_partitioner=None,
110 dense_layer_partitioner=None):
111 if not input:
112 raise ValueError("Dataset is not defined.")
113 self._feature = input[0]
114 self._label = input[1]
115
116 self._feature_column = feature_column
117 self._bottom_dnn = bottom_dnn
118 self._towers = towers
119 self._relation_dnn = relation_dnn
120
121 self._learning_rate = learning_rate
122 self.tf = stock_tf
123 self.bf16 = False if self.tf else bf16
124
125 self.is_training = True
126 self._adaptive_emb = adaptive_emb
127 self._optimizer_type = optimizer_type
128 self._input_layer_partitioner = input_layer_partitioner
129 self._dense_layer_partitioner = dense_layer_partitioner
130
131 self.model = self._create_model()
132 with tf.name_scope('head'):
133 self._create_loss()
134 self._create_optimizer()
135 self._create_metrics()
136
137 def _add_layer_summary(self, value, tag):
138 tf.summary.scalar('%s/fraction_of_zero_values' % tag,
139 tf.nn.zero_fraction(value))
140 tf.summary.histogram('%s/activation' % tag, value)
141
142 def _make_scope(self, name, bf16, part):
143 if(bf16):
144 return tf.variable_scope(name, partitioner=part, reuse=tf.AUTO_REUSE).keep_weights(dtype=tf.float32)
145 else:
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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected