Hello, I had the same issue and when update to 2.3.0, I got the following error.
AttributeError: type object ‘torch._C.Tag’ has no attribute ‘pt2_compliant_tag’
File , line 48
45 return correct.item() * 1.0 / len(labels)
47 model = SAGE(in_feats=n_features, hid_feats=100, out_feats=n_labels)
—> 48 opt = torch.optim.Adam(model.parameters())
50 for epoch in range(10):
51 model.train()
Code below, any advise would be grateful!
%pip install torch==2.3.0
%pip install dgl -f https://data.dgl.ai/wheels/torch-2.3/cu121/repo.html
import dgl
dataset = dgl.data.CiteseerGraphDataset()
graph = dataset[0]
import numpy as np
import torch
Contruct a two-layer GNN model
import dgl.nn as dglnn
import torch.nn as nn
import torch.nn.functional as F
class SAGE(nn.Module):
def __init__(self, in_feats, hid_feats, out_feats):
super().__init__()
self.conv1 = dglnn.SAGEConv(
in_feats=in_feats, out_feats=hid_feats, aggregator_type='mean')
self.conv2 = dglnn.SAGEConv(
in_feats=hid_feats, out_feats=out_feats, aggregator_type='mean')
def forward(self, graph, inputs):
# inputs are features of nodes
h = self.conv1(graph, inputs)
h = F.relu(h)
h = self.conv2(graph, h)
return h
node_features = graph.ndata[‘feat’]
node_labels = graph.ndata[‘label’]
train_mask = graph.ndata[‘train_mask’]
valid_mask = graph.ndata[‘val_mask’]
test_mask = graph.ndata[‘test_mask’]
n_features = node_features.shape[1]
n_labels = int(node_labels.max().item() + 1)
def evaluate(model, graph, features, labels, mask):
model.eval()
with torch.no_grad():
logits = model(graph, features)
logits = logits[mask]
labels = labels[mask]
_, indices = torch.max(logits, dim=1)
correct = torch.sum(indices == labels)
return correct.item() * 1.0 / len(labels)
model = SAGE(in_feats=n_features, hid_feats=100, out_feats=n_labels)
opt = torch.optim.Adam(model.parameters())