コード例 #1
0
np.random.seed(p.random_seed)
learn_rate = p.learn_rate
modelpath = make_model_directory()

if str(device) == 'cuda:0':
    epochs = p.epochs
else:
    epochs = 20

# ---- Importing and structuring Datasets and Model ----
print('Importing structures.')
# Remember!!! Shape Index can only be computed on local. Add other transforms after
# Pre_tranform step to not contaminate the data.
dataset = Structures(root='./datasets/{}_train/'.format(p.dataset),
                     pre_transform=Compose((FaceAttributes(), NodeCurvature(),
                                            FaceToEdge(), TwoHop())),
                     transform=AddShapeIndex())

samples = len(dataset)
assert (p.validation_split < 0.3)
cutoff = int(np.floor(samples * (1 - p.validation_split)))
trainset = dataset[:cutoff]
validset = dataset[cutoff:]
maskedset = validset[:int(len(validset) / 2)]
validset = validset[int(len(validset) / 2):]

if p.shuffle_dataset:
    trainset = trainset.shuffle()
n_features = trainset.get(0).x.shape[1]
print('Setting up model...')
models = [
コード例 #2
0
np.random.seed(p.random_seed)
learn_rate = p.learn_rate
modelpath = make_model_directory()

if str(device) == 'cuda:0':
    epochs = p.epochs
else:
    epochs = 20

# ---- Importing and structuring Datasets and Model ----
print('Importing structures.')
# Remember!!! Shape Index can only be computed on local. Add other transforms after
# Pre_tranform step to not contaminate the data.
dataset = Structures(root='./datasets/{}_train/'.format(p.dataset),
                      pre_transform=Compose((FaceAttributes(),
                                             NodeCurvature(), FaceToEdge(),
                                             TwoHop())),
                      transform=Compose((AddShapeIndex(), Center(), AddPositionalData())))


samples = len(dataset)
assert(p.validation_split < 0.3)
cutoff = int(np.floor(samples*(1-p.validation_split)))
trainset = dataset[:cutoff]
validset = dataset[cutoff:]
maskedset = validset[:int(len(validset)/2)]
validset = validset[int(len(validset)/2):]


if p.shuffle_dataset:
    trainset = trainset.shuffle()
コード例 #3
0
        print('{} not found'.format(name))

# rest done from command line.

import pathlib
pathlib.Path().absolute()

#Using the edge_index
import torch
from torch_geometric.transforms import FaceToEdge, PointPairFeatures
from dataset import MiniStructures
import pandas as pd
import numpy as np
from torch_geometric.data import DataLoader
dataset = MiniStructures(root='./datasets/mini/',
                         pre_transform=FaceToEdge(),
                         transform=PointPairFeatures())

dataset = MiniStructures()
dataloader = DataLoader(dataset, batch_size=20)
iterator = iter(dataloader)
batch = next(iterator)
batch.to_data_list()

dataset[0]
dataset[0].x.shape
edges = dataset[0].edge_index.t()
edges_df = pd.DataFrame(edges.numpy(), columns=['origin', 'destination'])

origins = torch.tensor(edges_df.origin.unique())
# max number of neighbors = 13