How to use the bigdl.util.common.get_activation_by_name function in bigdl

To help you get started, we’ve selected a few bigdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_gru_cell(self, klayer, kclayer, input_shape):  # create a gru cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        inner_activation = get_activation_by_name(config["inner_activation"],
                                                  "%s_%s" % (config["name"], config["inner_activation"]))
        gru = BLayer.GRU(input_size=int(input_shape[2]),
                         hidden_size=klayer.output_dim,
                         p=0.0,
                         activation=activation,
                         inner_activation=inner_activation,
                         wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                         uRegularizer=to_bigdl_reg(config["U_regularizer"]),
                         bRegularizer=to_bigdl_reg(config["b_regularizer"]),
                         bigdl_type="float")
        return gru
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_simplernn_cell(self, klayer, kclayer, input_shape):  # create a simplernn cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        rnn = BLayer.RnnCell(input_size=int(input_shape[2]),
                             hidden_size=klayer.output_dim,
                             activation=activation,
                             isInputWithBias=False,
                             wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                             uRegularizer=to_bigdl_reg(config["U_regularizer"]),
                             bRegularizer=to_bigdl_reg(config["b_regularizer"]),
                             bigdl_type="float")
        return rnn
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_lstm_cell(self, klayer, kclayer, input_shape):  # create a lstm cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        inner_activation = get_activation_by_name(config["inner_activation"],
                                                  "%s_%s" % (config["name"], config["inner_activation"]))
        lstm = BLayer.LSTM(input_size=int(input_shape[2]),
                           hidden_size=klayer.output_dim,
                           p=0.0,
                           activation=activation,
                           inner_activation=inner_activation,
                           wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                           uRegularizer=to_bigdl_reg(config["U_regularizer"]),
                           bRegularizer=to_bigdl_reg(config["b_regularizer"]),
                           bigdl_type="float")
        return lstm
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_convlstm2d_cell(self, klayer, kclayer, input_shape):  # create a convlstm2d cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        inner_activation = get_activation_by_name(config["inner_activation"],
                                                  "%s_%s" % (config["name"], config["inner_activation"]))

        convlstm = BLayer.ConvLSTMPeephole(input_size=int(input_shape[2]),
                                           output_size=config["nb_filter"],
                                           kernel_i=config["nb_col"],
                                           kernel_c=config["nb_row"],
                                           # NB: ConvLSTM doesn't serialize subsample to json file
                                           stride=klayer.subsample[0],
                                           padding=-1,
                                           activation=activation,
                                           inner_activation=inner_activation,
                                           # NB: ConvLSTM doesn't serialize regularizers to json file
                                           # wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                                           # uRegularizer=to_bigdl_reg(config["U_regularizer"]),
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_gru_cell(self, klayer, kclayer, input_shape):  # create a gru cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        inner_activation = get_activation_by_name(config["inner_activation"],
                                                  "%s_%s" % (config["name"], config["inner_activation"]))
        gru = BLayer.GRU(input_size=int(input_shape[2]),
                         hidden_size=klayer.output_dim,
                         p=0.0,
                         activation=activation,
                         inner_activation=inner_activation,
                         wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                         uRegularizer=to_bigdl_reg(config["U_regularizer"]),
                         bRegularizer=to_bigdl_reg(config["b_regularizer"]),
                         bigdl_type="float")
        return gru
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def generate_lstm_cell(self, klayer, kclayer, input_shape):  # create a lstm cell only
        self.__check_recurrent_parameters(klayer)
        config = kclayer["config"]
        activation = get_activation_by_name(config["activation"],
                                            "%s_%s" % (config["name"], config["activation"]))
        inner_activation = get_activation_by_name(config["inner_activation"],
                                                  "%s_%s" % (config["name"], config["inner_activation"]))
        lstm = BLayer.LSTM(input_size=int(input_shape[2]),
                           hidden_size=klayer.output_dim,
                           p=0.0,
                           activation=activation,
                           inner_activation=inner_activation,
                           wRegularizer=to_bigdl_reg(config["W_regularizer"]),
                           uRegularizer=to_bigdl_reg(config["U_regularizer"]),
                           bRegularizer=to_bigdl_reg(config["b_regularizer"]),
                           bigdl_type="float")
        return lstm
github intel-analytics / BigDL / pyspark / bigdl / keras / converter.py View on Github external
def create_highway(self):
        if self.config["activation"] == 'linear':
            activation = None
        else:
            activation = get_activation_by_name(self.config["activation"],
                                                "%s_%s" % (self.config["name"], self.config["activation"]))
        blayer = BLayer.Highway(size=int(self.input_shape[1]),
                                with_bias=self.klayer.bias,
                                activation=activation,
                                wRegularizer=to_bigdl_reg(self.config["W_regularizer"]),
                                bRegularizer=to_bigdl_reg(self.config["b_regularizer"]))
        return blayer