Muyi 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- muyi-0.0.0/LICENSE +16 -0
- muyi-0.0.0/Muyi.egg-info/PKG-INFO +16 -0
- muyi-0.0.0/Muyi.egg-info/SOURCES.txt +11 -0
- muyi-0.0.0/Muyi.egg-info/dependency_links.txt +1 -0
- muyi-0.0.0/Muyi.egg-info/top_level.txt +1 -0
- muyi-0.0.0/PKG-INFO +16 -0
- muyi-0.0.0/README.md +3 -0
- muyi-0.0.0/muyi/__init__.py +0 -0
- muyi-0.0.0/muyi/graph.py +42 -0
- muyi-0.0.0/muyi/utils.py +39 -0
- muyi-0.0.0/pyproject.toml +3 -0
- muyi-0.0.0/setup.cfg +4 -0
- muyi-0.0.0/setup.py +24 -0
muyi-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
4
|
+
in the Software without restriction, including without limitation the rights
|
|
5
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
6
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all
|
|
9
|
+
copies or substantial portions of the Software.
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Muyi
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Some useful utils.
|
|
5
|
+
Author: muyiiiii
|
|
6
|
+
Author-email:
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
# muyiiiii_graph
|
|
15
|
+
|
|
16
|
+
Some useful utils for GNNs.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
muyi
|
muyi-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Muyi
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Some useful utils.
|
|
5
|
+
Author: muyiiiii
|
|
6
|
+
Author-email:
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
# muyiiiii_graph
|
|
15
|
+
|
|
16
|
+
Some useful utils for GNNs.
|
muyi-0.0.0/README.md
ADDED
|
File without changes
|
muyi-0.0.0/muyi/graph.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import dgl
|
|
3
|
+
|
|
4
|
+
def pyg_data_to_dgl_graph(pyg_data_obj):
|
|
5
|
+
print(pyg_data_obj)
|
|
6
|
+
|
|
7
|
+
# 获取边索引
|
|
8
|
+
edge_index = pyg_data_obj.edge_index
|
|
9
|
+
|
|
10
|
+
# DGL需要的边索引格式是两列的数组,而不是两行的索引
|
|
11
|
+
src, dst = edge_index
|
|
12
|
+
edge_list = torch.stack((src, dst), dim=1)
|
|
13
|
+
|
|
14
|
+
# 创建DGL图
|
|
15
|
+
g = dgl.graph((edge_list[:, 0], edge_list[:, 1]), num_nodes=pyg_data_obj.x.shape[0])
|
|
16
|
+
|
|
17
|
+
# 添加节点特征
|
|
18
|
+
if 'x' in pyg_data_obj:
|
|
19
|
+
g.ndata['feature'] = pyg_data_obj.x
|
|
20
|
+
|
|
21
|
+
# 添加边特征
|
|
22
|
+
if 'edge_attr' in pyg_data_obj:
|
|
23
|
+
g.edata['feat'] = pyg_data_obj.edge_attr
|
|
24
|
+
|
|
25
|
+
# 添加节点标签
|
|
26
|
+
if 'y' in pyg_data_obj:
|
|
27
|
+
g.ndata['label'] = pyg_data_obj.y
|
|
28
|
+
|
|
29
|
+
# 添加节点标签
|
|
30
|
+
if 'train_mask' in pyg_data_obj:
|
|
31
|
+
g.ndata['train_mask'] = pyg_data_obj.train_mask
|
|
32
|
+
|
|
33
|
+
# 添加节点标签
|
|
34
|
+
if 'test_mask' in pyg_data_obj:
|
|
35
|
+
g.ndata['test_mask'] = pyg_data_obj.test_mask
|
|
36
|
+
|
|
37
|
+
# 添加节点标签
|
|
38
|
+
if 'val_mask' in pyg_data_obj:
|
|
39
|
+
g.ndata['val_mask'] = pyg_data_obj.val_mask
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
return g
|
muyi-0.0.0/muyi/utils.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
|
|
4
|
+
import GPUtil
|
|
5
|
+
|
|
6
|
+
def get_gpu_memory_usage():
|
|
7
|
+
# 获取GPU使用情况
|
|
8
|
+
gpus = GPUtil.getGPUs()
|
|
9
|
+
gpu_memory_info = []
|
|
10
|
+
for gpu in gpus:
|
|
11
|
+
gpu_memory_info.append((gpu.id, gpu.name, f"{gpu.memoryUsed} MB", f"{gpu.memoryTotal} MB", f"{gpu.memoryUtil * 100:.1f}%"))
|
|
12
|
+
|
|
13
|
+
return gpu_memory_info
|
|
14
|
+
|
|
15
|
+
def display_gpu_memory_usage():
|
|
16
|
+
gpu_memory_info = get_gpu_memory_usage()
|
|
17
|
+
|
|
18
|
+
if gpu_memory_info:
|
|
19
|
+
print("GPU Memory Usage:")
|
|
20
|
+
for info in gpu_memory_info:
|
|
21
|
+
print(f"GPU ID: {info[0]}, Name: {info[1]}, Memory Used: {info[2]}, Total Memory: {info[3]}, Memory Utilization: {info[4]}")
|
|
22
|
+
else:
|
|
23
|
+
print("No GPU found.")
|
|
24
|
+
|
|
25
|
+
def color_print(content):
|
|
26
|
+
print(f'\033[1;46m{content}\033[0m\n')
|
|
27
|
+
|
|
28
|
+
def save_pic_iterly(pic_name, postfix, info):
|
|
29
|
+
pic_idx=1
|
|
30
|
+
pic_name_full=f'{pic_name}_{pic_idx}.{postfix}'
|
|
31
|
+
|
|
32
|
+
while os.path.exists(pic_name_full):
|
|
33
|
+
print(f'File {pic_name_full} already exists.')
|
|
34
|
+
pic_idx += 1
|
|
35
|
+
pic_name_full=f'{pic_name}_{pic_idx}.png'
|
|
36
|
+
|
|
37
|
+
plt.savefig(pic_name_full, dpi=300, bbox_inches='tight')
|
|
38
|
+
|
|
39
|
+
color_print(f'!!!!! {info} is saved in file {pic_name_full}')
|
muyi-0.0.0/setup.cfg
ADDED
muyi-0.0.0/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
with open("README.md", "r") as fh:
|
|
3
|
+
long_description = fh.read()
|
|
4
|
+
setuptools.setup(
|
|
5
|
+
name="Muyi", # 模块名称
|
|
6
|
+
version="0.0.0", # 当前版本
|
|
7
|
+
author="muyiiiii", # 作者
|
|
8
|
+
author_email="", # 作者邮箱
|
|
9
|
+
description="Some useful utils.", # 模块简介
|
|
10
|
+
long_description=long_description, # 模块详细介绍
|
|
11
|
+
long_description_content_type="text/markdown", # 模块详细介绍格式
|
|
12
|
+
# url="", # 模块github地址
|
|
13
|
+
packages=setuptools.find_packages(), # 自动找到项目中导入的模块
|
|
14
|
+
# 模块相关的元数据
|
|
15
|
+
classifiers=[
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
],
|
|
20
|
+
# 依赖模块
|
|
21
|
+
install_requires=[
|
|
22
|
+
],
|
|
23
|
+
python_requires='>=3',
|
|
24
|
+
)
|