(self,
input,
feature_column,
num_experts,
expert_hidden_units,
towers,
dnn_activation=DNN_ACTIVATION,
num_layers=3,
expert_dnn_hidden_units=(256, 128, 64),
gate_dnn_hidden_units=(256, 128, 64),
shared_expert_num=1,
specific_expert_num=2,
optimizer_type='adam',
learning_rate=0.001,
use_bn=True,
bf16=False,
stock_tf=None,
adaptive_emb=False,
input_layer_partitioner=None,
dense_layer_partitioner=None)
| 109 | |
| 110 | class PLE(): |
| 111 | def __init__(self, |
| 112 | input, |
| 113 | feature_column, |
| 114 | num_experts, |
| 115 | expert_hidden_units, |
| 116 | towers, |
| 117 | dnn_activation=DNN_ACTIVATION, |
| 118 | num_layers=3, |
| 119 | expert_dnn_hidden_units=(256, 128, 64), |
| 120 | gate_dnn_hidden_units=(256, 128, 64), |
| 121 | shared_expert_num=1, |
| 122 | specific_expert_num=2, |
| 123 | optimizer_type='adam', |
| 124 | learning_rate=0.001, |
| 125 | use_bn=True, |
| 126 | bf16=False, |
| 127 | stock_tf=None, |
| 128 | adaptive_emb=False, |
| 129 | input_layer_partitioner=None, |
| 130 | dense_layer_partitioner=None): |
| 131 | if not input: |
| 132 | raise ValueError("Dataset is not defined.") |
| 133 | self._feature = input[0] |
| 134 | self._label = input[1] |
| 135 | self._feature_column = feature_column |
| 136 | self._num_experts = num_experts |
| 137 | self._expert_hidden_units = expert_hidden_units |
| 138 | self._towers = towers |
| 139 | self._num_tasks = len(towers) |
| 140 | self._num_layers = num_layers |
| 141 | self._dnn_activation = dnn_activation |
| 142 | |
| 143 | self._shared_expert_num = shared_expert_num |
| 144 | self._specific_expert_num = specific_expert_num |
| 145 | self._expert_dnn_hidden_units = expert_dnn_hidden_units |
| 146 | self._gate_dnn_hidden_units = gate_dnn_hidden_units |
| 147 | |
| 148 | self._learning_rate = learning_rate |
| 149 | self.tf = stock_tf |
| 150 | self._bf16 = False if self.tf else bf16 |
| 151 | self.use_bn = use_bn |
| 152 | |
| 153 | self.is_training = True |
| 154 | self._adaptive_emb = adaptive_emb |
| 155 | self._optimizer_type = optimizer_type |
| 156 | self._input_layer_partitioner = input_layer_partitioner |
| 157 | self._dense_layer_partitioner = dense_layer_partitioner |
| 158 | |
| 159 | self.model = self._create_model() |
| 160 | with tf.name_scope('head'): |
| 161 | self._create_loss() |
| 162 | self._create_optimizer() |
| 163 | self._create_metrics() |
| 164 | |
| 165 | # used to add summary in tensorboard |
| 166 | def _add_layer_summary(self, value, tag): |
nothing calls this directly
no test coverage detected