Пример #1
0
 def _mlp_layer(self, input, fc_type, hidden_units, dropouts, scope_name, reuse=False):
     if fc_type == "fc":
         output = dense_block(input, hidden_units=hidden_units, dropouts=dropouts,
                                          densenet=False, scope_name=scope_name,
                                          reuse=reuse,
                                          training=self.training, seed=self.params["random_seed"])
     elif fc_type == "densenet":
         output = dense_block(input, hidden_units=hidden_units, dropouts=dropouts,
                                          densenet=True, scope_name=scope_name,
                                          reuse=reuse,
                                          training=self.training, seed=self.params["random_seed"])
     elif fc_type == "resnet":
         output = resnet_block(input, hidden_units=hidden_units, dropouts=dropouts,
                                           cardinality=1, dense_shortcut=True, training=self.training,
                                           reuse=reuse,
                                           seed=self.params["random_seed"],
                                           scope_name=scope_name)
     return output
Пример #2
0
    def _score_fn_inner(self, x, reuse=False):
        # deep
        hidden_units = [self.params["fc_dim"] * 4, self.params["fc_dim"] * 2, self.params["fc_dim"]]
        dropouts = [self.params["fc_dropout"]] * len(hidden_units)
        out = dense_block(x, hidden_units=hidden_units, dropouts=dropouts, densenet=False, reuse=reuse,
                          training=self.training, seed=self.params["random_seed"])
        # score
        score = tf.layers.dense(out, 1, activation=None,
                                kernel_initializer=tf.glorot_uniform_initializer(seed=self.params["random_seed"]))

        return score
Пример #3
0
def multilayer_perceptron(x):
    hidden_units = [fc_dim]
    dropouts = [fc_dropout] * len(hidden_units)
    out_unit = dense_block(x,
                           hidden_units=hidden_units,
                           dropouts=dropouts,
                           densenet=False,
                           reuse=False,
                           training=True,
                           seed=random_seed,
                           bn=True)
    return out_unit