def buildRootInfo(self, name=""): """ Builds "solver" info object of the state dictionary """ from backend.caffe.path_loader import PathLoader proto = PathLoader().importProto() protosolver = proto.SolverParameter() descr = info.ParameterGroupDescriptor(protosolver) params = descr.parameter().copy() return self.buildInfo(name,params, [])
def loadSolver(solverstring): """ Return a dictionary which represent the caffe-solver-prototxt solverstring """ from backend.caffe.path_loader import PathLoader proto = PathLoader().importProto() solver = proto.SolverParameter() # Get DESCRIPTION for meta infos descr = info.ParameterGroupDescriptor(solver) # "Parse" the solver-definition in prototxt-format try: text_format.Merge(solverstring, solver) except ParseError as ex: raise ParseException(str(ex)) params = descr.parameter().copy() # All Parameters of the solver return copy.deepcopy(_extract_param(solver, params))
def _import_solver(solverdict): from backend.caffe.path_loader import PathLoader proto = PathLoader().importProto() solver = proto.SolverParameter() for entry in solverdict: # special case: inline-net definition in solver # (required to handle layers and layerOrder the same way it is handled for a standalone net definition) if entry == "net_param": net = _import_dictionary(solverdict["net_param"]) solver.net_param.MergeFrom(net) else: _insert(entry, solverdict[entry], solver) return solver
def extractNetFromSolver(solverstring): """Read a protoxt string(!) of a solver and return the network protoxt string(!). This works only, if the solver specifies a network using the "net_param" parameter. A reference to a file using the "net" parameter can not be handled by this method. """ from backend.caffe.path_loader import PathLoader proto = PathLoader().importProto() # create empty solver message solver = proto.SolverParameter() # "Parse" the solver-definition in prototxt-format try: text_format.Merge(solverstring, solver) # extract net as a message and convert it into a string netString = text_format.MessageToString(solver.net_param) return netString except ParseError as ex: raise ParseException(str(ex))