def __init__(self, jdata, descrpt): # model param self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() args = ClassArg()\ .add('numb_fparam', int, default = 0)\ .add('numb_aparam', int, default = 0)\ .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ .add('resnet_dt', bool, default = True)\ .add('rcond', float, default = 1e-3) \ .add('seed', int) \ .add('atom_ener', list, default = [])\ .add("activation_function", str, default = "tanh")\ .add("precision", str, default = "default")\ .add("trainable", [list, bool], default = True) class_data = args.parse(jdata) self.numb_fparam = class_data['numb_fparam'] self.numb_aparam = class_data['numb_aparam'] self.n_neuron = class_data['neuron'] self.resnet_dt = class_data['resnet_dt'] self.rcond = class_data['rcond'] self.seed = class_data['seed'] self.fitting_activation_fn = get_activation_func( class_data["activation_function"]) self.fitting_precision = get_precision(class_data['precision']) self.trainable = class_data['trainable'] if type(self.trainable) is bool: self.trainable = [self.trainable] * (len(self.n_neuron) + 1) assert (len(self.trainable) == len(self.n_neuron) + 1), 'length of trainable should be that of n_neuron + 1' self.atom_ener = [] for at, ae in enumerate(class_data['atom_ener']): if ae is not None: self.atom_ener.append( tf.constant(ae, global_tf_float_precision, name="atom_%d_ener" % at)) else: self.atom_ener.append(None) self.useBN = False self.bias_atom_e = None # data requirement if self.numb_fparam > 0: add_data_requirement('fparam', self.numb_fparam, atomic=False, must=True, high_prec=False) self.fparam_avg = None self.fparam_std = None self.fparam_inv_std = None if self.numb_aparam > 0: add_data_requirement('aparam', self.numb_aparam, atomic=True, must=True, high_prec=False) self.aparam_avg = None self.aparam_std = None self.aparam_inv_std = None
def __init__(self, jdata, descrpt): if not isinstance(descrpt, DescrptSeA): raise RuntimeError('PolarFittingSeA only supports DescrptSeA') self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() args = ClassArg()\ .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ .add('resnet_dt', bool, default = True)\ .add('fit_diag', bool, default = True)\ .add('diag_shift', [list,float], default = [0.0 for ii in range(self.ntypes)])\ .add('scale', [list,float], default = [1.0 for ii in range(self.ntypes)])\ .add('sel_type', [list,int], default = [ii for ii in range(self.ntypes)], alias = 'pol_type')\ .add('seed', int)\ .add("activation_function", str , default = "tanh")\ .add('precision', str, default = "default") class_data = args.parse(jdata) self.n_neuron = class_data['neuron'] self.resnet_dt = class_data['resnet_dt'] self.sel_type = class_data['sel_type'] self.fit_diag = class_data['fit_diag'] self.seed = class_data['seed'] self.diag_shift = class_data['diag_shift'] self.scale = class_data['scale'] self.fitting_activation_fn = get_activation_func( class_data["activation_function"]) self.fitting_precision = get_precision(class_data['precision']) if type(self.sel_type) is not list: self.sel_type = [self.sel_type] if type(self.diag_shift) is not list: self.diag_shift = [self.diag_shift] if type(self.scale) is not list: self.scale = [self.scale] self.dim_rot_mat_1 = descrpt.get_dim_rot_mat_1() self.dim_rot_mat = self.dim_rot_mat_1 * 3 self.useBN = False
def __init__ (self, jdata, descrpt): if not isinstance(descrpt, DescrptLocFrame) : raise RuntimeError('WFC only supports DescrptLocFrame') self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() args = ClassArg()\ .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ .add('resnet_dt', bool, default = True)\ .add('wfc_numb', int, must = True)\ .add('sel_type', [list,int], default = [ii for ii in range(self.ntypes)], alias = 'wfc_type')\ .add('seed', int)\ .add("activation_function", str, default = "tanh")\ .add('precision', str, default = "default")\ .add('uniform_seed', bool, default = False) class_data = args.parse(jdata) self.n_neuron = class_data['neuron'] self.resnet_dt = class_data['resnet_dt'] self.wfc_numb = class_data['wfc_numb'] self.sel_type = class_data['sel_type'] self.seed = class_data['seed'] self.uniform_seed = class_data['uniform_seed'] self.seed_shift = one_layer_rand_seed_shift() self.fitting_activation_fn = get_activation_func(class_data["activation_function"]) self.fitting_precision = get_precision(class_data['precision']) self.useBN = False
def __init__( self, neuron: List[int] = [], resnet_dt: bool = False, activation_function: str = 'tanh', precision: str = 'default', trainable: bool = True, seed: int = None, uniform_seed: bool = False, ) -> None: """ Constructor """ self.neuron = neuron self.seed = seed self.filter_resnet_dt = resnet_dt self.filter_precision = get_precision(precision) self.filter_activation_fn = get_activation_func(activation_function) self.trainable = trainable self.uniform_seed = uniform_seed
def __init__ (self, descrpt : tf.Tensor, neuron : List[int] = [120,120,120], resnet_dt : bool = True, sel_type : List[int] = None, seed : int = None, activation_function : str = 'tanh', precision : str = 'default', uniform_seed: bool = False ) -> None: """ Constructor """ if not isinstance(descrpt, DescrptSeA) : raise RuntimeError('DipoleFittingSeA only supports DescrptSeA') self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() # args = ClassArg()\ # .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ # .add('resnet_dt', bool, default = True)\ # .add('sel_type', [list,int], default = [ii for ii in range(self.ntypes)], alias = 'dipole_type')\ # .add('seed', int)\ # .add("activation_function", str, default = "tanh")\ # .add('precision', str, default = "default") # class_data = args.parse(jdata) self.n_neuron = neuron self.resnet_dt = resnet_dt self.sel_type = sel_type if self.sel_type is None: self.sel_type = [ii for ii in range(self.ntypes)] self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = one_layer_rand_seed_shift() self.fitting_activation_fn = get_activation_func(activation_function) self.fitting_precision = get_precision(precision) self.dim_rot_mat_1 = descrpt.get_dim_rot_mat_1() self.dim_rot_mat = self.dim_rot_mat_1 * 3 self.useBN = False self.fitting_net_variables = None self.mixed_prec = None
def __init__(self, jdata): args = ClassArg()\ .add('sel', list, must = True) \ .add('rcut', float, default = 6.0) \ .add('rcut_smth',float, default = 5.5) \ .add('neuron', list, default = [10, 20, 40]) \ .add('axis_neuron', int, default = 4, alias = 'n_axis_neuron') \ .add('resnet_dt',bool, default = False) \ .add('trainable',bool, default = True) \ .add('seed', int) \ .add('exclude_types', list, default = []) \ .add('set_davg_zero', bool, default = False) \ .add('activation_function', str, default = 'tanh') \ .add('precision', str, default = "default") class_data = args.parse(jdata) self.sel_a = class_data['sel'] self.rcut_r = class_data['rcut'] self.rcut_r_smth = class_data['rcut_smth'] self.filter_neuron = class_data['neuron'] self.n_axis_neuron = class_data['axis_neuron'] self.filter_resnet_dt = class_data['resnet_dt'] self.seed = class_data['seed'] self.trainable = class_data['trainable'] self.filter_activation_fn = get_activation_func( class_data['activation_function']) self.filter_precision = get_precision(class_data['precision']) exclude_types = class_data['exclude_types'] self.exclude_types = set() for tt in exclude_types: assert (len(tt) == 2) self.exclude_types.add((tt[0], tt[1])) self.exclude_types.add((tt[1], tt[0])) self.set_davg_zero = class_data['set_davg_zero'] # descrpt config self.sel_r = [0 for ii in range(len(self.sel_a))] self.ntypes = len(self.sel_a) assert (self.ntypes == len(self.sel_r)) self.rcut_a = -1 # numb of neighbors and numb of descrptors self.nnei_a = np.cumsum(self.sel_a)[-1] self.nnei_r = np.cumsum(self.sel_r)[-1] self.nnei = self.nnei_a + self.nnei_r self.ndescrpt_a = self.nnei_a * 4 self.ndescrpt_r = self.nnei_r * 1 self.ndescrpt = self.ndescrpt_a + self.ndescrpt_r self.useBN = False self.dstd = None self.davg = None self.place_holders = {} avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype(global_np_float_precision) std_ones = np.ones([self.ntypes, self.ndescrpt]).astype(global_np_float_precision) sub_graph = tf.Graph() with sub_graph.as_default(): name_pfx = 'd_sea_' for ii in ['coord', 'box']: self.place_holders[ii] = tf.placeholder( global_np_float_precision, [None, None], name=name_pfx + 't_' + ii) self.place_holders['type'] = tf.placeholder(tf.int32, [None, None], name=name_pfx + 't_type') self.place_holders['natoms_vec'] = tf.placeholder( tf.int32, [self.ntypes + 2], name=name_pfx + 't_natoms') self.place_holders['default_mesh'] = tf.placeholder( tf.int32, [None], name=name_pfx + 't_mesh') self.stat_descrpt, descrpt_deriv, rij, nlist \ = op_module.descrpt_se_a(self.place_holders['coord'], self.place_holders['type'], self.place_holders['natoms_vec'], self.place_holders['box'], self.place_holders['default_mesh'], tf.constant(avg_zero), tf.constant(std_ones), rcut_a = self.rcut_a, rcut_r = self.rcut_r, rcut_r_smth = self.rcut_r_smth, sel_a = self.sel_a, sel_r = self.sel_r) self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config)
def __init__(self, descrpt: tf.Tensor, neuron: List[int] = [120, 120, 120], resnet_dt: bool = True, numb_fparam: int = 0, numb_aparam: int = 0, rcond: float = 1e-3, tot_ener_zero: bool = False, trainable: List[bool] = None, seed: int = None, atom_ener: List[float] = [], activation_function: str = 'tanh', precision: str = 'default', uniform_seed: bool = False) -> None: """ Constructor """ # model param self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() # args = ()\ # .add('numb_fparam', int, default = 0)\ # .add('numb_aparam', int, default = 0)\ # .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ # .add('resnet_dt', bool, default = True)\ # .add('rcond', float, default = 1e-3) \ # .add('tot_ener_zero', bool, default = False) \ # .add('seed', int) \ # .add('atom_ener', list, default = [])\ # .add("activation_function", str, default = "tanh")\ # .add("precision", str, default = "default")\ # .add("trainable", [list, bool], default = True) self.numb_fparam = numb_fparam self.numb_aparam = numb_aparam self.n_neuron = neuron self.resnet_dt = resnet_dt self.rcond = rcond self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = one_layer_rand_seed_shift() self.tot_ener_zero = tot_ener_zero self.fitting_activation_fn = get_activation_func(activation_function) self.fitting_precision = get_precision(precision) self.trainable = trainable if self.trainable is None: self.trainable = [True for ii in range(len(self.n_neuron) + 1)] if type(self.trainable) is bool: self.trainable = [self.trainable] * (len(self.n_neuron) + 1) assert (len(self.trainable) == len(self.n_neuron) + 1), 'length of trainable should be that of n_neuron + 1' self.atom_ener = [] self.atom_ener_v = atom_ener for at, ae in enumerate(atom_ener): if ae is not None: self.atom_ener.append( tf.constant(ae, self.fitting_precision, name="atom_%d_ener" % at)) else: self.atom_ener.append(None) self.useBN = False self.bias_atom_e = np.zeros(self.ntypes, dtype=np.float64) # data requirement if self.numb_fparam > 0: add_data_requirement('fparam', self.numb_fparam, atomic=False, must=True, high_prec=False) self.fparam_avg = None self.fparam_std = None self.fparam_inv_std = None if self.numb_aparam > 0: add_data_requirement('aparam', self.numb_aparam, atomic=True, must=True, high_prec=False) self.aparam_avg = None self.aparam_std = None self.aparam_inv_std = None self.fitting_net_variables = None self.mixed_prec = None
def __init__(self, rcut: float, rcut_smth: float, sel: List[str], neuron: List[int] = [24, 48, 96], resnet_dt: bool = False, trainable: bool = True, seed: int = None, type_one_side: bool = True, exclude_types: List[List[int]] = [], set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'default', uniform_seed: bool = False) -> None: """ Constructor """ # args = ClassArg()\ # .add('sel', list, must = True) \ # .add('rcut', float, default = 6.0) \ # .add('rcut_smth',float, default = 0.5) \ # .add('neuron', list, default = [10, 20, 40]) \ # .add('resnet_dt',bool, default = False) \ # .add('trainable',bool, default = True) \ # .add('seed', int) \ # .add('type_one_side', bool, default = False) \ # .add('exclude_types', list, default = []) \ # .add('set_davg_zero', bool, default = False) \ # .add("activation_function", str, default = "tanh") \ # .add("precision", str, default = "default") # class_data = args.parse(jdata) self.sel_r = sel self.rcut = rcut self.rcut_smth = rcut_smth self.filter_neuron = neuron self.filter_resnet_dt = resnet_dt self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = embedding_net_rand_seed_shift(self.filter_neuron) self.trainable = trainable self.filter_activation_fn = get_activation_func(activation_function) self.filter_precision = get_precision(precision) exclude_types = exclude_types self.exclude_types = set() for tt in exclude_types: assert (len(tt) == 2) self.exclude_types.add((tt[0], tt[1])) self.exclude_types.add((tt[1], tt[0])) self.set_davg_zero = set_davg_zero self.type_one_side = type_one_side # descrpt config self.sel_a = [0 for ii in range(len(self.sel_r))] self.ntypes = len(self.sel_r) # numb of neighbors and numb of descrptors self.nnei_a = np.cumsum(self.sel_a)[-1] self.nnei_r = np.cumsum(self.sel_r)[-1] self.nnei = self.nnei_a + self.nnei_r self.ndescrpt_a = self.nnei_a * 4 self.ndescrpt_r = self.nnei_r * 1 self.ndescrpt = self.nnei_r self.useBN = False self.davg = None self.dstd = None self.embedding_net_variables = None self.place_holders = {} avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) std_ones = np.ones([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) sub_graph = tf.Graph() with sub_graph.as_default(): name_pfx = 'd_ser_' for ii in ['coord', 'box']: self.place_holders[ii] = tf.placeholder( GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + 't_' + ii) self.place_holders['type'] = tf.placeholder(tf.int32, [None, None], name=name_pfx + 't_type') self.place_holders['natoms_vec'] = tf.placeholder( tf.int32, [self.ntypes + 2], name=name_pfx + 't_natoms') self.place_holders['default_mesh'] = tf.placeholder( tf.int32, [None], name=name_pfx + 't_mesh') self.stat_descrpt, descrpt_deriv, rij, nlist \ = op_module.prod_env_mat_r(self.place_holders['coord'], self.place_holders['type'], self.place_holders['natoms_vec'], self.place_holders['box'], self.place_holders['default_mesh'], tf.constant(avg_zero), tf.constant(std_ones), rcut = self.rcut, rcut_smth = self.rcut_smth, sel = self.sel_r) self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config)
def __init__(self, rcut: float, rcut_smth: float, sel: List[str], neuron: List[int] = [24, 48, 96], axis_neuron: int = 8, resnet_dt: bool = False, trainable: bool = True, seed: int = None, type_one_side: bool = True, exclude_types: List[List[int]] = [], set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'default', uniform_seed: bool = False) -> None: """ Constructor """ if rcut < rcut_smth: raise RuntimeError( "rcut_smth (%f) should be no more than rcut (%f)!" % (rcut_smth, rcut)) self.sel_a = sel self.rcut_r = rcut self.rcut_r_smth = rcut_smth self.filter_neuron = neuron self.n_axis_neuron = axis_neuron self.filter_resnet_dt = resnet_dt self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = embedding_net_rand_seed_shift(self.filter_neuron) self.trainable = trainable self.compress_activation_fn = get_activation_func(activation_function) self.filter_activation_fn = get_activation_func(activation_function) self.filter_precision = get_precision(precision) self.exclude_types = set() for tt in exclude_types: assert (len(tt) == 2) self.exclude_types.add((tt[0], tt[1])) self.exclude_types.add((tt[1], tt[0])) self.set_davg_zero = set_davg_zero self.type_one_side = type_one_side # descrpt config self.sel_r = [0 for ii in range(len(self.sel_a))] self.ntypes = len(self.sel_a) assert (self.ntypes == len(self.sel_r)) self.rcut_a = -1 # numb of neighbors and numb of descrptors self.nnei_a = np.cumsum(self.sel_a)[-1] self.nnei_r = np.cumsum(self.sel_r)[-1] self.nnei = self.nnei_a + self.nnei_r self.ndescrpt_a = self.nnei_a * 4 self.ndescrpt_r = self.nnei_r * 1 self.ndescrpt = self.ndescrpt_a + self.ndescrpt_r self.useBN = False self.dstd = None self.davg = None self.compress = False self.embedding_net_variables = None self.mixed_prec = None self.place_holders = {} nei_type = np.array([]) for ii in range(self.ntypes): nei_type = np.append(nei_type, ii * np.ones(self.sel_a[ii])) # like a mask self.nei_type = tf.constant(nei_type, dtype=tf.int32) avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) std_ones = np.ones([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) sub_graph = tf.Graph() with sub_graph.as_default(): name_pfx = 'd_sea_' for ii in ['coord', 'box']: self.place_holders[ii] = tf.placeholder( GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + 't_' + ii) self.place_holders['type'] = tf.placeholder(tf.int32, [None, None], name=name_pfx + 't_type') self.place_holders['natoms_vec'] = tf.placeholder( tf.int32, [self.ntypes + 2], name=name_pfx + 't_natoms') self.place_holders['default_mesh'] = tf.placeholder( tf.int32, [None], name=name_pfx + 't_mesh') self.stat_descrpt, descrpt_deriv, rij, nlist \ = op_module.prod_env_mat_a(self.place_holders['coord'], self.place_holders['type'], self.place_holders['natoms_vec'], self.place_holders['box'], self.place_holders['default_mesh'], tf.constant(avg_zero), tf.constant(std_ones), rcut_a = self.rcut_a, rcut_r = self.rcut_r, rcut_r_smth = self.rcut_r_smth, sel_a = self.sel_a, sel_r = self.sel_r) self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config) self.original_sel = None
def __init__(self, rcut: float, rcut_smth: float, sel: List[str], neuron: List[int] = [24, 48, 96], resnet_dt: bool = False, trainable: bool = True, seed: int = None, set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'default', uniform_seed: bool = False) -> None: """ Constructor """ self.sel_a = sel self.rcut_r = rcut self.rcut_r_smth = rcut_smth self.filter_neuron = neuron self.filter_resnet_dt = resnet_dt self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = embedding_net_rand_seed_shift(self.filter_neuron) self.trainable = trainable self.filter_activation_fn = get_activation_func(activation_function) self.filter_precision = get_precision(precision) # self.exclude_types = set() # for tt in exclude_types: # assert(len(tt) == 2) # self.exclude_types.add((tt[0], tt[1])) # self.exclude_types.add((tt[1], tt[0])) self.set_davg_zero = set_davg_zero # descrpt config self.sel_r = [0 for ii in range(len(self.sel_a))] self.ntypes = len(self.sel_a) assert (self.ntypes == len(self.sel_r)) self.rcut_a = -1 # numb of neighbors and numb of descrptors self.nnei_a = np.cumsum(self.sel_a)[-1] self.nnei_r = np.cumsum(self.sel_r)[-1] self.nnei = self.nnei_a + self.nnei_r self.ndescrpt_a = self.nnei_a * 4 self.ndescrpt_r = self.nnei_r * 1 self.ndescrpt = self.ndescrpt_a + self.ndescrpt_r self.useBN = False self.dstd = None self.davg = None self.place_holders = {} avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) std_ones = np.ones([self.ntypes, self.ndescrpt]).astype(GLOBAL_NP_FLOAT_PRECISION) sub_graph = tf.Graph() with sub_graph.as_default(): name_pfx = 'd_sea_' for ii in ['coord', 'box']: self.place_holders[ii] = tf.placeholder( GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + 't_' + ii) self.place_holders['type'] = tf.placeholder(tf.int32, [None, None], name=name_pfx + 't_type') self.place_holders['natoms_vec'] = tf.placeholder( tf.int32, [self.ntypes + 2], name=name_pfx + 't_natoms') self.place_holders['default_mesh'] = tf.placeholder( tf.int32, [None], name=name_pfx + 't_mesh') self.stat_descrpt, descrpt_deriv, rij, nlist \ = op_module.prod_env_mat_a(self.place_holders['coord'], self.place_holders['type'], self.place_holders['natoms_vec'], self.place_holders['box'], self.place_holders['default_mesh'], tf.constant(avg_zero), tf.constant(std_ones), rcut_a = self.rcut_a, rcut_r = self.rcut_r, rcut_r_smth = self.rcut_r_smth, sel_a = self.sel_a, sel_r = self.sel_r) self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config)
def __init__ (self, descrpt : tf.Tensor, neuron : List[int] = [120,120,120], resnet_dt : bool = True, sel_type : List[int] = None, fit_diag : bool = True, scale : List[float] = None, shift_diag : bool = True, # YWolfeee: will support the user to decide whether to use this function #diag_shift : List[float] = None, YWolfeee: will not support the user to assign a shift seed : int = None, activation_function : str = 'tanh', precision : str = 'default', uniform_seed: bool = False ) -> None: """ Constructor Parameters ---------- descrpt : tf.Tensor The descrptor neuron : List[int] Number of neurons in each hidden layer of the fitting net resnet_dt : bool Time-step `dt` in the resnet construction: y = x + dt * \phi (Wx + b) sel_type : List[int] The atom types selected to have an atomic polarizability prediction. If is None, all atoms are selected. fit_diag : bool Fit the diagonal part of the rotational invariant polarizability matrix, which will be converted to normal polarizability matrix by contracting with the rotation matrix. scale : List[float] The output of the fitting net (polarizability matrix) for type i atom will be scaled by scale[i] diag_shift : List[float] The diagonal part of the polarizability matrix of type i will be shifted by diag_shift[i]. The shift operation is carried out after scale. seed : int Random seed for initializing the network parameters. activation_function : str The activation function in the embedding net. Supported options are {0} precision : str The precision of the embedding net parameters. Supported options are {1} uniform_seed Only for the purpose of backward compatibility, retrieves the old behavior of using the random seed """ if not isinstance(descrpt, DescrptSeA) : raise RuntimeError('PolarFittingSeA only supports DescrptSeA') self.ntypes = descrpt.get_ntypes() self.dim_descrpt = descrpt.get_dim_out() # args = ClassArg()\ # .add('neuron', list, default = [120,120,120], alias = 'n_neuron')\ # .add('resnet_dt', bool, default = True)\ # .add('fit_diag', bool, default = True)\ # .add('diag_shift', [list,float], default = [0.0 for ii in range(self.ntypes)])\ # .add('scale', [list,float], default = [1.0 for ii in range(self.ntypes)])\ # .add('sel_type', [list,int], default = [ii for ii in range(self.ntypes)], alias = 'pol_type')\ # .add('seed', int)\ # .add("activation_function", str , default = "tanh")\ # .add('precision', str, default = "default") # class_data = args.parse(jdata) self.n_neuron = neuron self.resnet_dt = resnet_dt self.sel_type = sel_type self.fit_diag = fit_diag self.seed = seed self.uniform_seed = uniform_seed self.seed_shift = one_layer_rand_seed_shift() #self.diag_shift = diag_shift self.shift_diag = shift_diag self.scale = scale self.fitting_activation_fn = get_activation_func(activation_function) self.fitting_precision = get_precision(precision) if self.sel_type is None: self.sel_type = [ii for ii in range(self.ntypes)] if self.scale is None: self.scale = [1.0 for ii in range(self.ntypes)] #if self.diag_shift is None: # self.diag_shift = [0.0 for ii in range(self.ntypes)] if type(self.sel_type) is not list: self.sel_type = [self.sel_type] self.constant_matrix = np.zeros(len(self.sel_type)) # len(sel_type) x 1, store the average diagonal value #if type(self.diag_shift) is not list: # self.diag_shift = [self.diag_shift] if type(self.scale) is not list: self.scale = [self.scale] self.dim_rot_mat_1 = descrpt.get_dim_rot_mat_1() self.dim_rot_mat = self.dim_rot_mat_1 * 3 self.useBN = False self.fitting_net_variables = None self.mixed_prec = None