예제 #1
0
    def _init_conv_layer_random(self, ilayer):

        # determine wih type of layer we want
        # first layer is a conv
        # we can't have 2 pool in a row
        if ilayer == 0:
            name = self.conv_types[0]

        # if rpevious layer is pool, next can't be pool
        elif self.conv_layers[ilayer - 1].__name__ == 'pool':
            name = np.random.choice(self.conv_types[:-1])

        # else it can be anything
        else:
            name = np.random.choice(self.conv_types)

        # init the parms of the layer
        # each layer type has its own params
        # the output/input size matching is done automatically
        if name == 'conv':
            params = {}
            params['name'] = name

            if ilayer == 0:
                params['input_size'] = -1  # fixed by input shape
            else:
                for isearch in range(ilayer - 1, -1, -1):
                    if self.conv_layers[isearch].__name__ == 'conv':
                        params['input_size'] = self.conv_layers[
                            isearch].output_size
                        break

            params['output_size'] = np.random.choice(
                self.conv_params['output_size'])
            params['kernel_size'] = np.random.choice(
                self.conv_params['kernel_size'])
            params['post'] = np.random.choice(self.post_types)

        if name == 'pool':
            params = {}
            params['name'] = name
            params['kernel_size'] = np.random.choice(
                self.pool_params['kernel_size'])
            params['post'] = np.random.choice(self.post_types)

        if name == 'dropout':
            params = {}
            params['name'] = name
            params['percent'] = np.random.choice(
                self.dropout_params['percent'])

        # create the current layer class instance
        # and initialize if with the __init_from_dict__() method
        current_layer = ast.list_eval(params['name'])()
        current_layer.__init_from_dict__(params)
        self.conv_layers.append(current_layer)
예제 #2
0
    def _init_fc_layer_random(self, ilayer):

        # init the parms of the layer
        # each layer type has its own params
        # the output/input size matching is done automatically
        name = 'fc'  # so far only fc layer here
        params = {}
        params['name'] = name
        if ilayer == 0:
            params['input_size'] = -1  # fixed by the conv layers
        else:
            params['input_size'] = self.fc_layers[ilayer - 1].output_size

        params['output_size'] = np.random.choice(self.fc_params['output_size'])
        params['post'] = np.random.choice(self.post_types)

        current_layer = ast.list_eval(params['name'])()
        current_layer.__init_from_dict__(params)
        self.fc_layers.append(current_layer)
예제 #3
0
    def render_transfer_file(self, restrict_currencies=None):
        if restrict_currencies and type(restrict_currencies) == str:
            restrict_currencies = ast.list_eval(restrict_currencies)
        # collect task information
        if self.aggregated == 1:
            """ aggregated method """
            data = {'transactions': self.get_aggregated_transactions()}

        else:
            # normal method (each document)
            data = {
                'transactions':
                self.get_individual_transactions(restrict_currencies)
            }

        content = frappe.render_template(
            'erpnextswiss/erpnextswiss/doctype/abacus_export_file/transfer_file.html',
            data)
        return {'content': content}