How to use __setattr__ right 0f Data in the torch_geometric.data

32 Views Asked by At

My code in one .py is:

data = Data(x=torch.from_numpy(task_input[pre_task_idx : row_idx, 2:]), edge_index=edge_mat)
add_order(data)
graph_inputs[idx] = data

in another .py is:

def add_order(graph):  
    ......

    graph.__setattr__("_idx0", a)
    graph.__setattr__("_index0", b)
    graph.__setattr__("_idx1", c)
    graph.__setattr__("_index1", d)

My question is "add_order_info_01(data)" runs successfully, but attributes like "_bi_layer_idx0" are not added into graph:

print("_idx0" in dir(graph))

False

I don't know why. Thank you.

0

There are 0 best solutions below