wkentaro / Pytorch For Numpy Users
Licence: mit
PyTorch for Numpy users. https://pytorch-for-numpy-users.wkentaro.com
Stars: ✭ 554
Projects that are alternatives of or similar to Pytorch For Numpy Users
Kymatio
Wavelet scattering transforms in Python with GPU acceleration
Stars: ✭ 396 (-28.52%)
Mutual labels: numpy
Dsp Theory
Theory of digital signal processing (DSP): signals, filtration (IIR, FIR, CIC, MAF), transforms (FFT, DFT, Hilbert, Z-transform) etc.
Stars: ✭ 437 (-21.12%)
Mutual labels: numpy
Pandapy
PandaPy has the speed of NumPy and the usability of Pandas 10x to 50x faster (by @firmai)
Stars: ✭ 474 (-14.44%)
Mutual labels: numpy
Deep learning nlp
Keras, PyTorch, and NumPy Implementations of Deep Learning Architectures for NLP
Stars: ✭ 407 (-26.53%)
Mutual labels: numpy
Salib
Sensitivity Analysis Library in Python (Numpy). Contains Sobol, Morris, Fractional Factorial and FAST methods.
Stars: ✭ 436 (-21.3%)
Mutual labels: numpy
Data Science Ipython Notebooks
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.
Stars: ✭ 22,048 (+3879.78%)
Mutual labels: numpy
Workshopscipy
A workshop for scientific computing in Python. ( December 2017 )
Stars: ✭ 391 (-29.42%)
Mutual labels: numpy
Tensor Sensor
The goal of this library is to generate more helpful exception messages for numpy/pytorch matrix algebra expressions.
Stars: ✭ 532 (-3.97%)
Mutual labels: numpy
Numpycnn
Building Convolutional Neural Networks From Scratch using NumPy
Stars: ✭ 436 (-21.3%)
Mutual labels: numpy
Mexican Government Report
Text Mining on the 2019 Mexican Government Report, covering from extracting text from a PDF file to plotting the results.
Stars: ✭ 473 (-14.62%)
Mutual labels: numpy
Pytablewriter
pytablewriter is a Python library to write a table in various formats: CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
Stars: ✭ 422 (-23.83%)
Mutual labels: numpy
Matrex
A blazing fast matrix library for Elixir/Erlang with C implementation using CBLAS.
Stars: ✭ 429 (-22.56%)
Mutual labels: numpy
Turbodbc
Turbodbc is a Python module to access relational databases via the Open Database Connectivity (ODBC) interface. The module complies with the Python Database API Specification 2.0.
Stars: ✭ 449 (-18.95%)
Mutual labels: numpy
Eagerpy
PyTorch, TensorFlow, JAX and NumPy — all of them natively using the same code
Stars: ✭ 520 (-6.14%)
Mutual labels: numpy
Geneticalgorithmpython
Source code of PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).
Stars: ✭ 435 (-21.48%)
Mutual labels: numpy
Tensorflow Exercises
TensorFlow Exercises - focusing on the comparison with NumPy.
Stars: ✭ 531 (-4.15%)
Mutual labels: numpy
Pynamical
Pynamical is a Python package for modeling and visualizing discrete nonlinear dynamical systems, chaos, and fractals.
Stars: ✭ 458 (-17.33%)
Mutual labels: numpy
PyTorch for Numpy users.
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) |
np.choose |
|
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 |
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].