使用 Machine Number Sense 数据集进行视觉算术推理
项目描述
机器编号意义
神经网络的 PyTorch 实现,用于解决机器数感 (MNS) 数据集[1]中的问题。可以在论文作者创建的这个 repo中找到基线模型的数据集和官方实现。
设置
$ pip install machine_number_sense
用法
基线模型
MLP [1]:
import torch
from mns.model import ConvMLP
x = torch.rand(4, 3, 80, 80)
mlp = ConvMLP(image_size=80)
logits = mlp(x)
logits # torch.Tensor with shape (4, 99)
LSTM [1]:
import torch
from mns.model import ConvLSTM
x = torch.rand(4, 3, 80, 80)
lstm = ConvLSTM(image_size=80)
logits = lstm(x)
logits # torch.Tensor with shape (4, 99)
实验模型
Scattering Compositional Learner (SCL) [2]适应来自 MNS 数据集的问题:
import torch
from mns.model import SCL
x = torch.rand(4, 3, 80, 80)
scl = SCL(image_size=80)
logits = scl(x)
logits # torch.Tensor with shape (4, 99)
用于解决 Raven 的渐进矩阵的 SCL 实现可以在这个 repo中找到。
神经算术逻辑单元 (NALU) [3]适用于 MNS:
import torch
from mns.model import ConvNALU
x = torch.rand(4, 3, 80, 80)
nalu = ConvNALU(image_size=80)
logits = nalu(x)
logits # torch.Tensor with shape (4, 99)
数据集
可以按照此 repo 中的说明获取 MNS 数据集。下载后可以加载:
from mns.dataset import MNSDataset
dataset = MNSDataset(data_dir='/path/to/dataset', image_size=80)
iterator = iter(dataset)
image, target = next(iterator)
image # torch.Tensor with shape (3, 80, 80)
target # torch.Tensor with shape ()
训练
文件mns.module包含一个PyTorch Lightning模块,用于在 MNS 上训练模型。可以使用scripts/目录中的脚本使用 Docker 运行训练。
单元测试
$ python -m pytest tests
参考书目
[1]张文和,等。“机器数感:用于抽象和关系推理的视觉算术问题数据集。” AAAI 人工智能会议论文集。2020 年。
[2]吴玉怀,等。“分散的组合学习者:在类比推理中发现对象、属性、关系。” arXiv 预印本 arXiv:2007.04212 (2020)。
[3]特拉斯克、安德鲁等人。“神经算术逻辑单元。” 神经信息处理系统的进展。2018 年。
引文
@inproceedings{zhang2020machine,
title={Machine number sense: A dataset of visual arithmetic problems for abstract and relational reasoning},
author={Zhang, Wenhe and Zhang, Chi and Zhu, Yixin and Zhu, Song-Chun},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={34},
number={02},
pages={1332--1340},
year={2020}
}
@article{wu2020scattering,
title={The Scattering Compositional Learner: Discovering Objects, Attributes, Relationships in Analogical Reasoning},
author={Wu, Yuhuai and Dong, Honghua and Grosse, Roger and Ba, Jimmy},
journal={arXiv preprint arXiv:2007.04212},
year={2020}
}
@inproceedings{trask2018neural,
title={Neural arithmetic logic units},
author={Trask, Andrew and Hill, Felix and Reed, Scott E and Rae, Jack and Dyer, Chris and Blunsom, Phil},
booktitle={Advances in Neural Information Processing Systems},
pages={8035--8044},
year={2018}
}
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
machine_number_sense-0.1.0.tar.gz
(7.6 kB
查看哈希)