Skip to main content

gravlearn

Project description

Unit Test & Deploy

import networkx as nx
import gravlearn as gn
import torch

# Load data
G = nx.karate_club_graph()
A = nx.adjacency_matrix(G)
labels = [G.nodes[i]["club"] for i in G.nodes]

# Generate the sequence for demo
sampler = gn.RandomWalkSampler(A, walk_length=40, p=1, q=1)
walks = [sampler.sampling(i) for _ in range(10) for i in range(A.shape[0])]

# Training
model = gravlearn.Word2Vec(A.shape[0], 32) # Embedding based on set

dist_metric = gravlearn.DistanceMetrics.EUCLIDEAN
model = gravlearn.train(model, walks, device = device, bags =A ,window_length=5, dist_metric=dist_metric)

# Embedding
emb = model.forward(torch.arange(A.shape[0]))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gravlearn-0.0.4-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file gravlearn-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: gravlearn-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for gravlearn-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a6392dd3fc34a1d3a74f14bdb23af2321904941c0e45b0ca00fc3028146ddc
MD5 c5b6960e3008bbfd43e3b21851eaee41
BLAKE2b-256 e03485694aef5ee01a1dbae7c1e0ae3e7047e7f3f88e6d28f628b977f3335466

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page