Skip to content

Commit 0ea846d

Browse files
committed
Update README.md
1 parent 8ffd4bf commit 0ea846d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ The Python implementation uses strings to specify the operation, but that would
1616
The `rearrange` combines reshaping and permutation operations into a single, expressive command:
1717

1818
```julia
19-
# Example from Python API
20-
images = randn(32, 30, 40, 3); # batch, height, width, channel
19+
julia> images = randn(32, 30, 40, 3); # batch, height, width, channel
2120

2221
# reorder axes to "b c h w" format:
23-
rearrange(images, (:b, :h, :w, :c) --> (:b, :c, :h, :w)) # (32, 3, 30, 40)
22+
julia> rearrange(images, (:b, :h, :w, :c) --> (:b, :c, :h, :w)) |> size
23+
(32, 3, 30, 40)
2424

2525
# flatten each image into a vector
26-
rearrange(images, (:b, :h, :w, :c) --> (:b, (:h, :w, :c))) # (32, 30*40*3)
26+
julia> rearrange(images, (:b, :h, :w, :c) --> (:b, (:h, :w, :c))) |> size
27+
(32, 3600)
2728

2829
# split each image into 4 smaller (top-left, top-right, bottom-left, bottom-right), 128 = 32 * 2 * 2
29-
rearrange(images, (:b, (:h1, :h), (:w1, :w), :c) --> ((:b, :h1, :w1), :h, :w, :c), h1=2, w1=2) # (128, 15, 20, 3)
30+
julia> rearrange(images, (:b, (:h1, :h), (:w1, :w), :c) --> ((:b, :h1, :w1), :h, :w, :c), h1=2, w1=2) |> size
31+
(128, 15, 20, 3)
3032
```
3133

3234
### `reduce` (Planned)

0 commit comments

Comments
 (0)