def load_params(self, path, exclude_free_params=False):
if not os.path.exists(path): return;<EOL>logging.info("<STR_LIT>" % path)<EOL>if exclude_free_params:<EOL><INDENT>params_to_load = self.parameters<EOL><DEDENT>else:<EOL><INDENT>params_to_load = self.all_parameters<EOL><DEDENT>if path.endswith("<STR_LIT>"):<EOL><INDENT>opener = gzip.open if path.lower().endswith('<STR_LIT>') else open<EOL>handle = opener(path, '<STR_LIT:rb>')<EOL>saved_params = pickle.load(handle)<EOL>handle.close()<EOL>for target, source in zip(params_to_load, saved_params):<EOL><INDENT>logging.info('<STR_LIT>', target.name, source.shape)<EOL>target.set_value(source)<EOL><DEDENT><DEDENT>elif path.endswith("<STR_LIT>"):<EOL><INDENT>arrs = np.load(path)<EOL>for target, idx in zip(params_to_load, range(len(arrs.keys()))):<EOL><INDENT>source = arrs['<STR_LIT>' % idx]<EOL>logging.info('<STR_LIT>', target.name, source.shape)<EOL>target.set_value(source)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % path)<EOL><DEDENT>self.train_logger.load(path)<EOL>
Load parameters from file.