def generate(self, model_len=None, model_width=None):
        """Generates a Multi-Layer Perceptron.
        Args:
            model_len: An integer. Number of hidden layers.
            model_width: An integer or a list of integers of length `model_len`. If it is a list, it represents the
                number of nodes in each hidden layer. If it is an integer, all hidden layers have nodes equal to this
                value.
        Returns:
            An instance of the class Graph. Represents the neural architecture graph of the generated model.
        """
        if model_len is None:
            model_len = Constant.MODEL_LEN
        if model_width is None:
            model_width = Constant.MODEL_WIDTH
        if isinstance(model_width, list) and not len(model_width) == model_len:
            raise ValueError("The length of 'model_width' does not match 'model_len'")
        elif isinstance(model_width, int):
            model_width = [model_width] * model_len

        graph = Graph(self.input_shape, False)
        output_node_id = 0
        n_nodes_prev_layer = self.input_shape[0]
        for width in model_width:
            output_node_id = graph.add_layer(
                StubDense(n_nodes_prev_layer, width), output_node_id
            )
            output_node_id = graph.add_layer(
                StubDropout1d(Constant.MLP_DROPOUT_RATE), output_node_id
            )
            output_node_id = graph.add_layer(StubReLU(), output_node_id)
            n_nodes_prev_layer = width

        graph.add_layer(StubDense(n_nodes_prev_layer, self.n_output_node), output_node_id)
        return graph
def generate ( self , model_len = None , model_width = None ) : if model_len is None : model_len = Constant . MODEL_LEN if model_width is None : model_width = Constant . MODEL_WIDTH if isinstance ( model_width , list ) and not len ( model_width ) == model_len : raise ValueError ( "The length of 'model_width' does not match 'model_len'" ) elif isinstance ( model_width , int ) : model_width = [ model_width ] * model_len graph = Graph ( self . input_shape , False ) output_node_id = 0 n_nodes_prev_layer = self . input_shape [ 0 ] for width in model_width : output_node_id = graph . add_layer ( StubDense ( n_nodes_prev_layer , width ) , output_node_id ) output_node_id = graph . add_layer ( StubDropout1d ( Constant . MLP_DROPOUT_RATE ) , output_node_id ) output_node_id = graph . add_layer ( StubReLU ( ) , output_node_id ) n_nodes_prev_layer = width graph . add_layer ( StubDense ( n_nodes_prev_layer , self . n_output_node ) , output_node_id ) return graph
Generates a Multi-Layer Perceptron.
        Args:
            model_len: An integer. Number of hidden layers.
            model_width: An integer or a list of integers of length `model_len`. If it is a list, it represents the
                number of nodes in each hidden layer. If it is an integer, all hidden layers have nodes equal to this
                value.
        Returns:
            An instance of the class Graph. Represents the neural architecture graph of the generated model.