arogozhnikov / einops

Flexible and powerful tensor operations for readable and reliable code (for pytorch, jax, TF and others)
https://einops.rocks
MIT License
8.55k stars 352 forks source link

[BUG] Basic code from documentation does not work #320

Closed vignesh99 closed 6 months ago

vignesh99 commented 6 months ago

I tried both the codes described below from the official docs and it does not seem to work

# change it to RGB format by repeating in each channel
>>> repeat(image, 'h w -> h w c', c=3).shape
(30, 40, 3)

# repeat image 2 times along height (vertical axis)
>>> repeat(image, 'h w -> (repeat h) w', repeat=2).shape
(60, 40)

I get the following errors

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<__array_function__ internals>", line 198, in repeat
TypeError: repeat() got an unexpected keyword argument 'c'

and

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<__array_function__ internals>", line 198, in repeat
TypeError: repeat() got an unexpected keyword argument 'repeat'

Since it is the official documentation code, I thought it is better to ask here and get a quick answer instead of asking stackoverflow (none of the chatbot fixes worked). Below is the version of einops I have:

pip show einops
Name: einops
Version: 0.8.0
Summary: A new flavour of deep learning operations
Home-page: 
Author: Alex Rogozhnikov
Author-email: 
License: MIT
Location: /Users/myname/.pyenv/versions/3.8.16/lib/python3.8/site-packages
Requires: 
Required-by: 

Please let me know how to fix this, I'm in a bit of hurry.

arogozhnikov commented 6 months ago

@vignesh99 you imported repeat from somewhere else (likely numpy) not einops.