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

Class BST

modelzoo/bst/train.py:60–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class BST():
61 def __init__(self,
62 user_column=None,
63 item_column=None,
64 tag_column=None,
65 key_column=None,
66 final_hidden_units=[512, 256, 64],
67 learning_rate=0.001,
68 max_seqence_length=50,
69 multi_head_size=4,
70 batch_size=0,
71 optimizer_type='adam',
72 use_bn=True,
73 inputs=None,
74 bf16=False,
75 stock_tf=None,
76 adaptive_emb=False,
77 input_layer_partitioner=None,
78 dense_layer_partitioner=None):
79 if not inputs:
80 raise ValueError("Dataset is not defined.")
81 self._feature = inputs[0]
82 self._label = inputs[1]
83
84 self._unseq_column = user_column + item_column
85 self._tag_column = tag_column
86 self._key_column = key_column
87 self._batch_size = batch_size
88 if not user_column or not item_column or not tag_column or not key_column:
89 raise ValueError('Feature column is not defined.')
90
91 self.tf = stock_tf
92 self.bf16 = False if self.tf else bf16
93 self.is_training = True
94 self._adaptive_emb = adaptive_emb
95
96 self._final_hidden_units = final_hidden_units
97 self._max_seqence_length = max_seqence_length
98 self._multi_head_size = multi_head_size
99 self._learning_rate = learning_rate
100 self._use_bn = use_bn
101 self._optimizer_type = optimizer_type
102 self._input_layer_partitioner = input_layer_partitioner
103 self._dense_layer_partitioner = dense_layer_partitioner
104
105 self._create_model()
106 with tf.name_scope('head'):
107 self._create_loss()
108 self._create_optimizer()
109 self._create_metrics()
110
111 # used to add summary in tensorboard
112 def _add_layer_summary(self, value, tag):
113 tf.summary.scalar('%s/fraction_of_zero_values' % tag,
114 tf.nn.zero_fraction(value))
115 tf.summary.histogram('%s/activation' % tag, value)
116
117 def _add_and_norm(self, net_1, net_2, emb_dim, name='add_and_norm'):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected