README.md 874 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
# PyTorch Scatter
rusty1s's avatar
rusty1s committed
2

rusty1s's avatar
rusty1s committed
3
<p align="center">
rusty1s's avatar
smaller  
rusty1s committed
4
  <img width="50%" src="https://raw.githubusercontent.com/rusty1s/pytorch_scatter/master/docs/source/_figures/add.svg?sanitize=true" />
rusty1s's avatar
rusty1s committed
5
6
7
8
</p>

--------------------------------------------------------------------------------

rusty1s's avatar
rusty1s committed
9
10
11
12
13
14
15
16
17
18
* `scatter_add`
* `scatter_sub`
* `scatter_mul`
* `scatter_div`
* `scatter_mean`
* `scatter_min`
* `scatter_max`

## Installation

rusty1s's avatar
rusty1s committed
19
```sh
rusty1s's avatar
rusty1s committed
20
python setup.py install
rusty1s's avatar
rusty1s committed
21
22
```

rusty1s's avatar
rusty1s committed
23
24
## Usage

rusty1s's avatar
rusty1s committed
25
26
27
```py
from torch_scatter import scatter_max

rusty1s's avatar
typos  
rusty1s committed
28
29
input = torch.Tensor([[2, 0, 1, 4, 3], [0, 2, 1, 3, 4]])
index = torch.LongTensor([[4, 5, 4, 2, 3], [0, 0, 2, 2, 1]])
rusty1s's avatar
rusty1s committed
30

rusty1s's avatar
typos  
rusty1s committed
31
max, argmax = scatter_max_(index, input, dim=1)
rusty1s's avatar
typo  
rusty1s committed
32
```
rusty1s's avatar
rusty1s committed
33

rusty1s's avatar
typo  
rusty1s committed
34
```
rusty1s's avatar
typos  
rusty1s committed
35
36
37
38
print(max)
 0  0  4  3  2  0
 2  4  3  0  0  0
[torch.FloatTensor of size 2x6]
rusty1s's avatar
rusty1s committed
39

rusty1s's avatar
typos  
rusty1s committed
40
41
42
43
44
print(argmax)
-1 -1  3  4  0  1
 1  4  3 -1 -1 -1
[torch.LongTensor of size 2x6]
```
rusty1s's avatar
rusty1s committed
45
46
47
48
49
50

## Running tests

```sh
python setup.py test
```