# Broadcastable variables and arrays

**URL:** <https://community.konduit.ai/t/broadcastable-variables-and-arrays/2758>\
**Category:** SameDiff\
**Created:** [August 5, 2023, 7:41pm UTC](https://community.konduit.ai/t/broadcastable-variables-and-arrays/2758 "2023-08-05T19:41:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adonnini](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adonnini](https://community.konduit.ai/u/adonnini)\
**Post date:** [August 5, 2023, 7:41pm UTC](https://community.konduit.ai/t/broadcastable-variables-and-arrays/2758/1 "2023-08-05T19:41:09Z")

</div>

Hi,  
I have read all the documentation about broadcast and searched on the web for “nd4j broadcast”.

I could not find any information to help me resolve this error:

`shapes are not equal and are not broadcastable`

The operation that fails is a simple `sub`

I tried using `sub` in samediff applying it do the two SD variables,  
one with shape [32, 6, 33]  
sub  
the other with shape [32, 6, 512]

I extracted the underlying arrays and tried the INDArray version of `sub`.

All with the same result.

I thought that even though the two variables/arrays do not have the same shape, under-the-cover broadcast would fix that and make `sub` work.

Clearly, I am doing something wrong and missing something obvious.

By the way, I also tried to use broadcast to try and align the two arrays. As expected, it did not work.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [August 10, 2023, 12:31am UTC](https://community.konduit.ai/t/broadcastable-variables-and-arrays/2758/2 "2023-08-10T00:31:21Z")

</div>

@adonnini broadcastable usually means you have something like an array minus a scalar or a matrix minus a vector.

You’ll have to put a 1 somewhere in there for it to work like reshape 1,3,1,2.
