Giter Site home page Giter Site logo

Comments (1)

hailiang-wang avatar hailiang-wang commented on July 16, 2024 1

将network中的参数dump到存储空间,然后增加load方法。
比如:

 def dumps(self, file_path):
        '''
        Dump nn parameters into file
        '''
        dumps.write(dict({
                         "input_layer_size": self.input_layer_size,
                         "output_layer_size": self.output_layer_size,
                         "layers": self.layers,
                         "layers_num": self.layers_num,
                         "weights": [ y.tolist() for y in self.weights],
                         "biases": [ y.tolist() for y in self.biases],
                         "epoch": self.epoch,
                         "lr": self.lr,
                         "batch_size": self.batch_size,
                         "eval_every_N_steps": self.eval_every_N_steps,
                         "train_data_file": self.train_data_file,
                         "test_data_file": self.test_data_file
                         }), file_path)



    def loads(self, file_path):
        '''
        load neural network parameters
        '''
        data = dumps.read(file_path)
        if "input_layer_size" in data:
            self.input_layer_size = data['input_layer_size']


        if "output_layer_size" in data:
            self.output_layer_size = data['output_layer_size']


        if "layers" in data:
            self.layers = data['layers']


        if "layers_num" in data:
            self.layers_num = data['layers_num']
            print("loads: %s" % "layers_num")

        if "weights" in data:
            self.weights = [ np.array(x) for x in data['weights']]
            print("loads: %s" % "weights")

        if "biases" in data:
            self.biases = [ np.array(x) for x in data['biases']]


        if "epoch" in data:
            self.epoch = data['epoch']


        if "lr" in data:
            self.lr = data['lr']


        if "batch_size" in data:
            self.batch_size = data['batch_size']


        if "eval_every_N_steps" in data:
            self.eval_every_N_steps = data['eval_every_N_steps']


        if "train_data_file" in data:
            self.train_data_file = data['train_data_file']



from insuranceqa-corpus-zh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.