def _train(self): """ Train the model """ self._setup() tmp = self.rmtsc self.rmtsc = None inputs = {"self": self} with cached_operation(inputs, self.options["data_dir"]) as outputs: self.rmtsc = tmp if outputs: self.sol_coeff = outputs["sol_coeff"] self.sol = outputs["sol"] self.mtx = outputs["mtx"] self.full_dof2coeff = outputs["full_dof2coeff"] self.full_hess = outputs["full_hess"] self.full_jac_dict = outputs["full_jac_dict"] else: self._new_train() outputs["sol_coeff"] = self.sol_coeff outputs["sol"] = self.sol outputs["mtx"] = self.mtx outputs["full_dof2coeff"] = self.full_dof2coeff outputs["full_hess"] = self.full_hess outputs["full_jac_dict"] = self.full_jac_dict
def _train(self): """ Train the model """ self._setup() tmp = self.rmtsc self.rmtsc = None inputs = {'self': self} with cached_operation(inputs, self.options['data_dir']) as outputs: self.rmtsc = tmp if outputs: self.sol_coeff = outputs['sol_coeff'] self.sol = outputs['sol'] self.mtx = outputs['mtx'] self.full_dof2coeff = outputs['full_dof2coeff'] self.full_hess = outputs['full_hess'] self.full_jac_dict = outputs['full_jac_dict'] else: self._new_train() outputs['sol_coeff'] = self.sol_coeff outputs['sol'] = self.sol outputs['mtx'] = self.mtx outputs['full_dof2coeff'] = self.full_dof2coeff outputs['full_hess'] = self.full_hess outputs['full_jac_dict'] = self.full_jac_dict
def _train(self): """ Train the model """ inputs = {"self": self} with cached_operation(inputs, self.options["data_dir"]) as outputs: if outputs: self.sol = outputs["sol"] else: self._new_train()
def _train(self): """ Train the model """ inputs = {'self': self} with cached_operation(inputs, self.options['data_dir']) as outputs: if outputs: self.sol = outputs['sol'] else: self._new_train()
def _compute_energy_terms(self): # This computes the energy terms that are to be minimized. # The quadrature points are the centroids of the multi-dimensional elements. num = self.num xlimits = self.options["xlimits"] inputs = {} inputs["nx"] = xlimits.shape[0] inputs["elem_list"] = num["elem_list"] if self.__class__.__name__ == "RMTB": inputs["num_ctrl_list"] = num["ctrl_list"] inputs["order_list"] = num["order_list"] if self.options["save_energy_terms"]: cache_dir = self.options["data_dir"] else: cache_dir = None with cached_operation(inputs, cache_dir) as outputs: if outputs: sq_mtx = outputs["sq_mtx"] else: n = np.prod(2 * num["elem_list"]) x = np.empty(n * num["x"]) self.rmtsc.compute_quadrature_points( n, np.array(2 * num["elem_list"], dtype=np.int32), x ) x = x.reshape((n, num["x"])) sq_mtx = [None] * num["x"] for kx in range(num["x"]): mtx = self._compute_jac(kx + 1, kx + 1, x) sq_mtx[kx] = ( mtx.T.tocsc() * mtx * (xlimits[kx, 1] - xlimits[kx, 0]) ** 4 ) outputs["sq_mtx"] = sq_mtx elem_vol = np.prod((xlimits[:, 1] - xlimits[:, 0]) / (2 * num["elem_list"])) total_vol = np.prod(xlimits[:, 1] - xlimits[:, 0]) full_hess = scipy.sparse.csc_matrix((num["dof"], num["dof"])) for kx in range(num["x"]): full_hess += sq_mtx[kx] * ( elem_vol / total_vol * self.options["smoothness"][kx] / (xlimits[kx, 1] - xlimits[kx, 0]) ** 4 ) return full_hess
def _train(self): """ Train the model """ self._setup() tmp = self.idwc self.idwc = None inputs = {'self': self} with cached_operation(inputs, self.options['data_dir']) as outputs: self.idwc = tmp if outputs: self.sol = outputs['sol'] else: self._new_train()
def _train(self): """ Train the model """ self._setup() tmp = self.rbfc self.rbfc = None inputs = {"self": self} with cached_operation(inputs, self.options["data_dir"]) as outputs: self.rbfc = tmp if outputs: self.sol = outputs["sol"] else: self._new_train() outputs["sol"] = self.sol