Source code for torch_geometric.io.txt_array

import torch


[docs]def parse_txt_array(src, sep=None, start=0, end=None, dtype=None, device=None): src = [[float(x) for x in line.split(sep)[start:end]] for line in src] src = torch.tensor(src, dtype=dtype).squeeze() return src
[docs]def read_txt_array(path, sep=None, start=0, end=None, dtype=None, device=None): with open(path, 'r') as f: src = f.read().split('\n')[:-1] return parse_txt_array(src, sep, start, end, dtype, device)