def fetch_dataset(molecule_type, is_triu=True, index=None): dim = DIM[molecule_type] def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] if is_triu: dataset, molecules = make_butadien_dataset( np.load( "cc2ai/" + \ molecule_type + "/molecules_" + molecule_type + "_6-31g**.npy" ), *load_triu(*np.load( "cc2ai/" + \ molecule_type + "/dataset_" + molecule_type + "_6-31g**.npy" ), dim), index=index ) else: dataset, molecules = make_butadien_dataset( np.load( "cc2ai/" + \ molecule_type + "/molecules_" + molecule_type + "_6-31g**.npy" ), *np.load( "cc2ai/" + \ molecule_type + "/dataset_" + molecule_type + "_6-31g**.npy" ), index=index ) return dataset, molecules
def fetch_dataset(folder, postfix, is_triu=True, index=None, test_samples=100): dim = DIM if is_triu: molecules = np.load(folder + "molecules" + postfix + ".npy") descriptor = NonWeighted( Gaussians(*RADIAL_GAUSSIAN_MODELS["Equidistant-Broadening_1"]), Gaussians(*AZIMUTHAL_GAUSSIAN_MODELS["Equisitant_1"]), Gaussians(*POLAR_GAUSSIAN_MODELS["Equisitant_1"]) ) descriptor_values = descriptor.calculate_descriptors_batch(molecules) dataset, molecules = make_butadien_dataset( molecules, descriptor_values, [extract_triu(p, DIM) for p in np.load(folder + "P" + postfix + ".npy")], index=index, test_samples=test_samples ) S = np.load(folder + "S" + postfix + ".npy") if index is None: index = np.arange(len(S)) S_test = S[index[test_samples:]] else: raise NotImplementedError("Only triu networks!!") return dataset, molecules, S_test
def prep_dataset(): """Fetching the dataset """ def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] folder = join("butadien", "data", "400") molecules = np.load(join(folder, "molecules400.npy")) descriptor = NonWeighted( Gaussians(*RADIAL_GAUSSIAN_MODELS["Equidistant-Broadening_1"]), Gaussians(*AZIMUTHAL_GAUSSIAN_MODELS["Equisitant_1"]), Gaussians(*POLAR_GAUSSIAN_MODELS["Equisitant_1"]) ) descriptor_values = descriptor.calculate_descriptors_batch(molecules) dataset, molecules = make_butadien_dataset( molecules, descriptor_values, [extract_triu(p, DIM) for p in np.load(join(folder, "P400.npy"))], test_samples=100 ) return dataset#, molecules
def fetch_dataset(folder, postfix, is_triu=True, index=None): dim = DIM def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] if is_triu: dataset, molecules = make_butadien_dataset( np.load( folder + "molecules" + postfix + ".npy" ), *load_triu( np.load(folder + "S" + postfix + ".npy"), np.load(folder + "P" + postfix + ".npy"), dim ), index=index, test_samples=100 ) else: raise NotImplementedError("Only triu networks!!") return dataset, molecules
def prep_dataset(): """Fetching the dataset """ def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] folder = join("butadien", "data") dataset, molecules = make_butadien_dataset( np.load(join(folder, "molecules.npy")), np.load(join(folder, "S.npy")), np.load(join(folder, "P.npy"))) return dataset #, molecules
def prep_dataset(): """Fetching the dataset """ def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] folder = join("butadien", "data", "400") dataset, molecules = make_butadien_dataset( np.load(join(folder, "molecules400.npy")), *load_triu(np.load(join(folder, "S400.npy")), np.load(join(folder, "P400.npy")), DIM), test_samples=100) return dataset #, molecules
def prep_dataset(molecule_type): """Fetching the dataset """ def load_triu(S, P, dim): return [extract_triu(s, dim) for s in S], [extract_triu(p, dim) for p in P] folder = join("cc2ai", molecule_type) dataset, molecules = make_butadien_dataset( np.load( join( folder, "molecules_" + molecule_type + "_" + BASIS[molecule_type] + ".npy")), *load_triu( *np.load( join( folder, "dataset_" + molecule_type + "_" + BASIS[molecule_type] + ".npy")), DIM[molecule_type]), ) return dataset #, molecules
def main(sample_index): msg.print_level = 2 msg.info("Hi. Measurements for butadien", 2) #--- fetch dataset and constants --- msg.info("Fetching sample " + str(sample_index) + " from datase", 2) dim = DIM molecules = np.load( "butadien/data/molecules.npy" ) S = np.load( "butadien/data/S.npy") P = np.load( "butadien/data/P.npy") dataset = make_butadien_dataset(molecules, S, P)[0] molecule = molecules[sample_index].get_pyscf_molecule() s = S[sample_index].reshape(dim, dim) s_normed = dataset.inverse_input_transform(s.reshape(1, -1)).reshape(1,-1) p = P[sample_index].reshape(dim, dim) #--- #--- fetch network --- msg.info("Fetching pretained network ", 2) graph = tf.Graph() structure, weights, biases = np.load( "butadien/data/network.npy", encoding="latin1" ) with graph.as_default(): sess = tf.Session() network = EluFixedValue(structure, weights, biases) network.setup() sess.run(tf.global_variables_initializer()) #--- #--- calculate guesses --- msg.info("Calculating guesses ...",2) msg.info("Neural network ", 1) p_nn = network.run(sess, s_normed).reshape(dim, dim) msg.info("McWheenys", 1) p_mcw1 = multi_mc_wheeny(p_nn, s, n_max=1) p_mcw5 = multi_mc_wheeny(p_nn, s, n_max=5) msg.info("Classics", 1) p_sap = hf.init_guess_by_atom(molecule) p_minao = hf.init_guess_by_minao(molecule) p_gwh = hf.init_guess_by_wolfsberg_helmholtz(molecule) #--- #--- Measureing & print --- outfile = "butadien/results/cube_" + str(sample_index) + "_" msg.info("Results Converged ", 1) cubegen.density(molecule, outfile + "converged.cube", p.astype("float64")) msg.info("Results NN: ", 1) cubegen.density(molecule, outfile + "nn.cube", p_nn.astype("float64")) msg.info("Results McWheeny 1: ",1) cubegen.density(molecule, outfile + "mcw1.cube", p_mcw1.astype("float64")) msg.info("Results McWheeny 5: ", 1) cubegen.density(molecule, outfile + "mcw5.cube", p_mcw5.astype("float64")) msg.info("Results SAP: ", 1) cubegen.density(molecule, outfile + "sap.cube", p_sap) msg.info("Results MINAO: ", 1) cubegen.density(molecule, outfile + "minao.cube", p_minao) msg.info("Results GWH: ", 1) cubegen.density(molecule, outfile + "gwh.cube", p_gwh)