• Stars
    star
    660
  • Rank 65,952 (Top 2 %)
  • Language
    HTML
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PyTorch for Numpy users. https://pytorch-for-numpy-users.wkentaro.com

PyTorch for Numpy users.

ci gh-pages

PyTorch version of Torch for Numpy users.
We assume you use the latest PyTorch and Numpy.

How to contribute?

git clone https://github.com/wkentaro/pytorch-for-numpy-users.git
cd pytorch-for-numpy-users
vim conversions.yaml
git commit -m "Update conversions.yaml"

./run_tests.py

Types

Numpy PyTorch
np.ndarray
torch.Tensor
np.float32
torch.float32; torch.float
np.float64
torch.float64; torch.double
np.float16
torch.float16; torch.half
np.int8
torch.int8
np.uint8
torch.uint8
np.int16
torch.int16; torch.short
np.int32
torch.int32; torch.int
np.int64
torch.int64; torch.long

Ones and zeros

Numpy PyTorch
np.empty((2, 3))
torch.empty(2, 3)
np.empty_like(x)
torch.empty_like(x)
np.eye
torch.eye
np.identity
torch.eye
np.ones
torch.ones
np.ones_like
torch.ones_like
np.zeros
torch.zeros
np.zeros_like
torch.zeros_like

From existing data

Numpy PyTorch
np.array([[1, 2], [3, 4]])
torch.tensor([[1, 2], [3, 4]])
np.array([3.2, 4.3], dtype=np.float16)
np.float16([3.2, 4.3])
torch.tensor([3.2, 4.3], dtype=torch.float16)
x.copy()
x.clone()
x.astype(np.float32)
x.type(torch.float32); x.float()
np.fromfile(file)
torch.tensor(torch.Storage(file))
np.frombuffer
np.fromfunction
np.fromiter
np.fromstring
np.load
torch.load
np.loadtxt
np.concatenate
torch.cat

Numerical ranges

Numpy PyTorch
np.arange(10)
torch.arange(10)
np.arange(2, 3, 0.1)
torch.arange(2, 3, 0.1)
np.linspace
torch.linspace
np.logspace
torch.logspace

Linear algebra

Numpy PyTorch
np.dot
torch.dot   # 1D arrays only
torch.mm    # 2D arrays only
torch.mv    # matrix-vector (2D x 1D)
np.matmul
torch.matmul
np.tensordot
torch.tensordot
np.einsum
torch.einsum

Building matrices

Numpy PyTorch
np.diag
torch.diag
np.tril
torch.tril
np.triu
torch.triu

Attributes

Numpy PyTorch
x.shape
x.shape; x.size()
x.strides
x.stride()
x.ndim
x.dim()
x.data
x.data
x.size
x.nelement()
x.dtype
x.dtype

Indexing

Numpy PyTorch
x[0]
x[0]
x[:, 0]
x[:, 0]
x[indices]
x[indices]
np.take(x, indices)
torch.take(x, torch.LongTensor(indices))
x[x != 0]
x[x != 0]

Shape manipulation

Numpy PyTorch
x.reshape
x.reshape; x.view
x.resize()
x.resize_
x.resize_as_
x = np.arange(6).reshape(3, 2, 1)
x.transpose(2, 0, 1)  # 012 -> 201
x = torch.arange(6).reshape(3, 2, 1)
x.permute(2, 0, 1); x.transpose(1, 2).transpose(0, 1)  # 012 -> 021 -> 201
x.flatten
x.view(-1)
x.squeeze()
x.squeeze()
x[:, None]; np.expand_dims(x, 1)
x[:, None]; x.unsqueeze(1)

Item selection and manipulation

Numpy PyTorch
np.put
x.put
x.put_
x = np.array([1, 2, 3])
x.repeat(2)  # [1, 1, 2, 2, 3, 3]
x = torch.tensor([1, 2, 3])
x.repeat_interleave(2)  # [1, 1, 2, 2, 3, 3]
x.repeat(2)  # [1, 2, 3, 1, 2, 3]
x.repeat(2).reshape(2, -1).transpose(1, 0).reshape(-1)
# [1, 1, 2, 2, 3, 3]
np.tile(x, (3, 2))
x.repeat(3, 2)
x = np.array([[0, 1], [2, 3], [4, 5]])
idxs = np.array([0, 2])
np.choose(idxs, x) # [0, 5]
x = torch.tensor([[0, 1], [2, 3], [4, 5]])
idxs = torch.tensor([0, 2])
x[idxs, torch.arange(x.shape[1])] # [0, 5]
torch.gather(x, 0, idxs[None, :])[0] # [0, 5]
np.sort
sorted, indices = torch.sort(x, [dim])
np.argsort
sorted, indices = torch.sort(x, [dim])
np.nonzero
torch.nonzero
np.where
torch.where
x[::-1]
torch.flip(x, [0])
np.unique(x)
torch.unique(x)

Calculation

Numpy PyTorch
x.min
x.min
x.argmin
x.argmin
x.max
x.max
x.argmax
x.argmax
x.clip
x.clamp
x.round
x.round
np.floor(x)
torch.floor(x); x.floor()
np.ceil(x)
torch.ceil(x); x.ceil()
x.trace
x.trace
x.sum
x.sum
x.sum(axis=0)
x.sum(0)
x.cumsum
x.cumsum
x.mean
x.mean
x.std
x.std
x.prod
x.prod
x.cumprod
x.cumprod
x.all
x.all
x.any
x.any

Arithmetic and comparison operations

Numpy PyTorch
np.less
x.lt
np.less_equal
x.le
np.greater
x.gt
np.greater_equal
x.ge
np.equal
x.eq
np.not_equal
x.ne

Random numbers

Numpy PyTorch
np.random.seed
torch.manual_seed
np.random.permutation(5)
torch.randperm(5)

Numerical operations

Numpy PyTorch
np.sign
torch.sign
np.sqrt
torch.sqrt

More Repositories

1

labelme

Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation).
Python
10,986
star
2

gdown

Download a large file from Google Drive (curl/wget fails because of the security notice).
Python
3,407
star
3

pytorch-fcn

PyTorch Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)
Python
1,695
star
4

imgviz

Image Visualization Tools (object detection, semantic and instance segmentation)
Python
232
star
5

morefusion

MoreFusion: Multi-object Reasoning for 6D Pose Estimation from Volumetric Fusion, CVPR 2020
Python
222
star
6

fcn

Chainer Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)
Python
218
star
7

video-cli

Command line tools for quick video editing.
Python
121
star
8

gshell

Navigate in Google Drive as you do on shell (gshell = Google Drive + Shell).
Python
102
star
9

octomap-python

Python binding of the OctoMap library.
Cython
71
star
10

call-python-from-cpp

Example Code of Calling Python from C++ with PyBind11.
C++
57
star
11

chainer-mask-rcnn

Chainer Implementation of Mask R-CNN. (Training code to reproduce the original result is available.)
Python
55
star
12

reorientbot

ReorientBot: Learning Object Reorientation for Specific-Posed Placement, ICRA 2022
Python
49
star
13

safepicking

SafePicking: Learning Safe Object Extraction via Object-Level Mapping, ICRA 2022
Python
48
star
14

pascal3d

Toolkit for PASCAL3D dataset.
Python
32
star
15

dotfiles

My dotfiles.
Shell
31
star
16

conque.vim

[MIRROR] Run interactive commands inside a Vim buffer.
Python
23
star
17

moviepy-cli

Command line interface for MoviePy.
Python
23
star
18

logboard

logboard: Monitor and Compare Logs on Browser/Terminal.
Python
21
star
19

label-fusion

Volumetric Fusion of Multiple Semantic Labels and Masks
C++
19
star
20

jqk

Render a JSON with jq patterns.
Rust
16
star
21

github2pypi

Release tools from GitHub to PyPi.
Python
14
star
22

imgviz-cpp

Image Visualization Tools for C++
C++
13
star
23

hrp2_apc

3D Object Segmentation for Shelf Bin Picking by Humanoid with Deep Learning and Occupancy Voxel Grid Map (Humanoids2016)
Common Lisp
12
star
24

chainer-cyclegan

Chainer implementation of "Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Network".
Python
10
star
25

sdf-object-model-descriptor

Python
8
star
26

screenshot-manager

Organize screenshot/screencast in a uniform manner.
Python
7
star
27

pytorch-fc-densenet

Python
7
star
28

chainer-bicyclegan

Chainer implementation of "Toward Multimodal Image-to-Image Translation".
Python
7
star
29

rfcn

Recurrent Fully Convolutional Networks for Instance-level Object Segmentation.
Python
7
star
30

pycd

`cd` to python modules.
Python
7
star
31

homebrew-trr

[DEPRECATED] TRR (typing software on Emacs) as formula for Homebrew.
Ruby
5
star
32

vgg16

VGG16 object recognition network. (Chainer Implementation)
Python
5
star
33

apc-object-detection

Object detection for Amazon Picking Challenge.
Python
5
star
34

cython_catkin_example

Simple example of Catkin + Cython.
CMake
5
star
35

real-harem

Transgender of real persons to achieve real harem, with mixed reality on Hololens.
Python
4
star
36

togif

Moved to https://github.com/wkentaro/video-cli
Python
4
star
37

label_octomap

Probabilistic 3D Multilabel Real-time Mapping for Multi-object Manipulation (IROS2017)
Python
4
star
38

gotenshita

See Gotenshita(ๅพกๆฎฟไธ‹) court open status.
Python
4
star
39

chainer-modelzoo

Model-Zoo for Chainer.
Python
4
star
40

imgviz_ros

Python
3
star
41

covid-vs-vaccine-mortality-japan

ใ‚ณใƒญใƒŠ็ฝนๆ‚ฃใจใƒฏใ‚ฏใƒใƒณๆŽฅ็จฎใฎๆญปไบก็Ž‡ๆฏ”่ผƒ
Python
3
star
42

Install-trr

Installation script for TRR (typing software on Emacs) on Ubuntu.
Shell
3
star
43

jsk_201604_cmo

Catch Moving Object (CMO) task project from April 2016.
Python
3
star
44

lecture2017s-agent-system

2
star
45

wstool_cd

`cd` to repos in workspace managed by wstool.
Python
2
star
46

python-packages

Python
2
star
47

continuous_teaching

CMake
2
star
48

wkentaro.github.io

My personal page.
HTML
2
star
49

ros-tips

Tips to be left as written text.
2
star
50

CV

My curriculum vitae (CV).
TeX
2
star
51

jqk-python

Render a JSON with jq patterns. Faster version in Rust -> https://github.com/wkentaro/jqk
Python
2
star
52

lecture2014w-utmi-intelligent-mechano-informatics

Assignments of Intelligent Mechano Informatics lesson.
Python
2
star
53

convenience_store_objects

CMake
2
star
54

lecture2016a-aai-ist

Jupyter Notebook
2
star
55

homebrew-labelme

Homebrew installation of labelme.
Ruby
2
star
56

pytorch-vgg

Python
2
star
57

jsk_20160407_evaluate_realsense

Shell
1
star
58

jsk_20160405_vacuum2015_graspability

Python
1
star
59

smile-of-the-day

Python
1
star
60

apc-object-detection-old

Python
1
star
61

trimesh-glooey

Python
1
star
62

hackerrank

Python
1
star
63

tensorflow-fcn

Python
1
star
64

google-calendar-manager

Python
1
star
65

auto-argcomplete

๐Ÿ Auto argument completion util for human.
Python
1
star
66

mysite.com

django tutorial package (mysite.com)
Python
1
star
67

d-image-pipeline

Python
1
star
68

logcal

CSS
1
star
69

lecture2016w-advanced-statistical-modeling-report

TeX
1
star
70

lecture2017s-image-system

C++
1
star
71

acml-paper-template

TeX
1
star
72

euspy

Common Lisp
1
star
73

multisettings

Tool to handle multiple settings for editor, shell and other command line tools.
Python
1
star
74

reference

Python
1
star
75

octomap-python-wheels

Build wheels for wkentaro/octomap-python.
Shell
1
star
76

personal-notes

My personal notes.
Python
1
star
77

awesome-eus

A curated list of awesome Euslisp documents, functions and macros.
Common Lisp
1
star
78

Introduction2Algorithms

Python
1
star
79

cython-tutorials

Python
1
star
80

citations

[DEPRECATED] My citations.
TeX
1
star
81

jsk-data-aries-scripts

Shell
1
star
82

dakoku

dakoku
Python
1
star
83

keyopener

[Now site is pending..] Making product project in the class in UTokyo named "Jishupro".
Python
1
star
84

apc-data

Python
1
star
85

lecture2014w-utmi-pattern-information

Implementation of some models for pattern recognition. (Assignments of class in UTokyo "Pattern Information")
Python
1
star
86

gci-case-study

Case Study in GCI, which is a program improving the skills of analyzing big data.
Python
1
star
87

jsk_20160505_test_message_filters

Testing message_filters Python interface in JSK on May 5th in 2016.
Python
1
star
88

wstool_catkin

catkin env hooks providing bash completion and setting ROS_WORKSPACE in devel space
EmberScript
1
star
89

homebrew-pycd

Homebrew tap repository for wkentaro/pycd.
Ruby
1
star
90

lecture2014s-utmech-soft2

Sample codes in "ใ‚ฝใƒ•ใƒˆใ‚ฆใ‚งใ‚ข็ฌฌไบŒ", which is a class about software engineering in UTokyo.
Python
1
star
91

utaskweb_syllabus

crawling the contents in UTask-Web
Python
1
star
92

eus-for-pythonista

Common Lisp
1
star
93

test-euslisp-in-package

Common Lisp
1
star
94

lora

Hubot named lora, who is working in JSK Robotics Team.
CoffeeScript
1
star
95

ros-pkg

Python
1
star
96

bibtex

TeX
1
star
97

py-fast-rcnn

Python
1
star
98

jsk_20160228_evaluate_pick_and_verify

Python
1
star
99

ros_beginner_tutorials

ROS pakage for beginners served at http://wiki.ros.org.
Python
1
star
100

effective-python

Python
1
star