IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

batch.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import scipy.sparse as sp
  2. class Batch(object):
  3. def __init__(self, adjacency_matrix):
  4. pass
  5. def get(size):
  6. pass
  7. def train_test_split(data, train_size=.8):
  8. pass
  9. class Minibatch(object):
  10. def __init__(self, data, node_type_row, node_type_column, size):
  11. self.data = data
  12. self.adjacency_matrix = data.get_adjacency_matrix(node_type_row, node_type_column)
  13. self.size = size
  14. self.order = np.random.permutation(adjacency_matrix.nnz)
  15. self.count = 0
  16. def reset(self):
  17. self.count = 0
  18. self.order = np.random.permutation(adjacency_matrix.nnz)
  19. def __iter__(self):
  20. adj_mat = self.adjacency_matrix
  21. size = self.size
  22. order = np.random.permutation(adj_mat.nnz)
  23. for i in range(0, len(order), size):
  24. row = adj_mat.row[i:i + size]
  25. col = adj_mat.col[i:i + size]
  26. data = adj_mat.data[i:i + size]
  27. adj_mat_batch = sp.coo_matrix((data, (row, col)), shape=adj_mat.shape)
  28. yield adj_mat_batch
  29. degree = self.adjacency_matrix.sum(1)
  30. def __len__(self):
  31. pass