zoukankan      html  css  js  c++  java
  • pytorch_geometric 源码学习

    项目地址:https://github.com/rusty1s/pytorch_geometric

    作者大神真的太屌了,膜拜,工程实现能力太强了

    本文希望能够记录学习其源码的过程

    data / dataset 部分(涉及优化?)

    语法

    @property 

    一种Python内置装饰器,可以将一个成员函数当成成员变量来访问,

    例如:

    class Planetoid(InMemoryDataset):
        
        url = 'https://github.com/kimiyoung/planetoid/raw/master/data'
    
        def __init__(self, root, name, transform=None, pre_transform=None):
            self.name = name
            super(Planetoid, self).__init__(root, transform, pre_transform)
            self.data, self.slices = torch.load(self.processed_paths[0])
    
        @property
        def raw_dir(self):
            return osp.join(self.root, self.name, 'raw')
    
        @property
        def processed_dir(self):
            return osp.join(self.root, self.name, 'processed')
    
        @property
        def raw_file_names(self):
            names = ['x', 'tx', 'allx', 'y', 'ty', 'ally', 'graph', 'test.index']
            return ['ind.{}.{}'.format(self.name.lower(), name) for name in names]
    
        @property
        def processed_file_names(self):
            return 'data.pt'
    
        def __repr__(self):
            return '{}()'.format(self.name)

    可以直接调用

    dataset = Planetoid(path, dataset, T.NormalizeFeatures())
    raw_file_names = dataset.raw_file_names

    可参考:https://www.liaoxuefeng.com/wiki/897692888725344/923030547069856

    __repr__(self)
    Python内置函数,自定义输出对象信息

    可参考:http://c.biancheng.net/view/2367.html

    (待更)

  • 相关阅读:
    scala-隐式转换
    scala-泛型
    scala-模式匹配
    scala-LinkedList
    scala-高阶函数
    scala-数组/列表
    scala-map
    scala语法
    机器学习笔记
    Day 1 下午
  • 原文地址:https://www.cnblogs.com/sbj123456789/p/12543913.html
Copyright © 2011-2022 走看看