Esempio n. 1
0
    def prepare(self):
        # split train and test
        self.training_events = self.dataset[:self.n_training_events]
        self.test_events = self.dataset[self.n_training_events:]
        # set up model
        self.model = Graph_ConvNet(self.options)
        self.grid_side = self.options['grid_side']
        self.number_edges = self.options['number_edges']
        self.metric = self.options['metric']
        # create graph of Euclidean grid
        self.Grid = grid_graph(self.grid_side, self.number_edges, self.metric)

        # Compute coarsened graphs
        self.L, self.perm = coarsen(self.Grid, self.options['coarsening'])
        lmax = []
        for i in range(self.options['coarsening']):
            lmax.append(lmax_L(self.L[i]))
        self.options['D'] = max(perm) + 1
        self.options['FC1Fin'] = self.options['CL2_F'] * \
            (self.options['D'] // 16)
print(val_labels.shape)
print(test_data.shape)
print(test_labels.shape)

from grid_graph import grid_graph
from coarsening import coarsen
from coarsening import lmax_L
from coarsening import perm_data
from coarsening import rescale_L

# Construct graph
t_start = time.time()
grid_side = 28
number_edges = 4
metric = 'euclidean'
A = grid_graph(grid_side, number_edges,
               metric)  # create graph of Euclidean grid

# Compute coarsened graphs
coarsening_levels = 4

L, perm = coarsen(A, coarsening_levels)

# Compute max eigenvalue of graph Laplacians
lmax = []
for i in range(coarsening_levels):
    lmax.append(lmax_L(L[i]))
print('lmax: ' + str([lmax[i] for i in range(coarsening_levels)]))

# Reindex nodes to satisfy a binary tree structure
train_data = perm_data(train_data, perm)
val_data = perm_data(val_data, perm)
Esempio n. 3
0
File: mnist.py Progetto: hacors/Drug
                       help="gpu id, use cpu if set to -1")
argparser.add_argument("--model",
                       type=str,
                       default="chebnet",
                       help="model to use, chebnet/monet")
argparser.add_argument("--batch-size",
                       type=int,
                       default=100,
                       help="batch size")
args = argparser.parse_args()

grid_side = 28
number_edges = 8
metric = 'euclidean'

A = grid_graph(28, 8, metric)

coarsening_levels = 4
L, perm = coarsen(A, coarsening_levels)
g_arr = [DGLGraph(csr) for csr in L]

coordinate_arr = get_coordinates(g_arr, grid_side, coarsening_levels, perm)
for g, coordinate_arr in zip(g_arr, coordinate_arr):
    g.ndata['xy'] = coordinate_arr
    g.apply_edges(z2polar)


def batcher(batch):
    g_batch = [[] for _ in range(coarsening_levels + 1)]
    x_batch = []
    y_batch = []