Esempio n. 1
0
                    help='Number of clusters.')
parser.add_argument('--dropout',
                    type=float,
                    default=0.,
                    help='Dropout rate (1 - keep probability).')

args = parser.parse_args()
args.cuda = not args.no_cuda and torch.cuda.is_available()

np.random.seed(args.seed)
torch.manual_seed(args.seed)
if args.cuda:
    torch.cuda.manual_seed(args.seed)

adj, features = load_gene_data(use_features=True,
                               _adj='homology',
                               _feat='ontology')

# create graph from adjacency matrix
G = nx.from_numpy_matrix(adj.toarray())

# print(adj.shape)
#
# print(G.number_of_edges())
# print(G.number_of_nodes())

adj_label = adj
adj_label = torch.FloatTensor(adj_label.toarray())

adj_train = preprocess_graph(adj)
Esempio n. 2
0
                    default=0.,
                    help='Dropout rate (1 - keep probability).')
parser.add_argument('--saved-model',
                    type=str,
                    default='models/gae',
                    help='Saved model')

args = parser.parse_args()
args.cuda = not args.no_cuda and torch.cuda.is_available()

np.random.seed(args.seed)
torch.manual_seed(args.seed)
if args.cuda:
    torch.cuda.manual_seed(args.seed)

adj, features = load_gene_data()
G = nx.from_numpy_matrix(adj.toarray())
adj_train = preprocess_graph(adj)

model = GCNModelAE(nfeat=features.shape[1],
                   nhid=args.hidden,
                   nclass=args.ndim,
                   dropout=args.dropout)
model.load_state_dict(torch.load(args.saved_model))
model.eval()

model(features, adj_train)
output = model.mu.data

# Normalize the output data
data = output