Modifying strides only means you can't reason about data locality. What if you are doing fft and you need to transpose to make it go fast?

And yes, numpy's lack of rank as well as its braindead conformability rules mean you need to munge shape in superfluous ways.

On Wed, 15 Jun 2022, Alex Shroyer wrote:

I use NumPy a lot for work, and something I realized when listening to this
podcast was that I use NumPy's equivalent to dyadic transpose _all the
time_ for machine learning tasks.

Recently I had to transpose an array of N 64x64 RGB images (shape: N, 3,
64, 64) into something like (shape: N, 64, 64, 3).

The fact that NumPy transpose is almost "free" (because it modifies strides
in-place, rather than copying data) is its saving grace, because NumPy is
lacking in other areas (i.e. no rank operator, trailing axis instead of
leading axis match), and therefore needs to do transposes more often.

On Wed, Jun 15, 2022 at 7:30 PM Marshall Lochbaum <mwlochb...@gmail.com>
wrote:

I think it's quite reasonable to solve your "general" problem by
applying a transpose, and maybe filling in some length-1 axes, before an
n-dimensional Kronecker product. There's a reason BQN still has a
Reorder Axes primitive! The Kronecker product alone is interesting
because it can easily be seen as a transpose even though it's something
that was developed outside of this context.

To be clear, my opposition to J's flat array model (I think it's almost
always worse than BQN's based model) is different from my stance on flat
arrays. BQN can also represent and optimize these, although there's no
name for the category; they'd be called arrays of numbers or arrays of
characters. And of course there can be huge advantages to working with
them, but I think it's madness to use this as grounds to dismiss a
solution that's much shorter and easier to read. And frankly, more in
keeping with other array principles: that blind reshape ($,) on the
transposed array is something I try hard to avoid.

Marshall

On Wed, Jun 15, 2022 at 03:18:03PM -0700, Elijah Stone wrote:
> 1. Refer to henry baker, 'On the Permutations of a Vector Obtainable
through
> the Restructure and Transpose Operators of APL'
> (https://plover.com/~mjd/misc/hbaker-archive/APLPerms.ps.Z).  I don't
think
> it is a _particularly_ good paper, but it is alright, and it is relevant.
>
> 2. Your join is interesting, but it is not fully general, and it is
> decidedly contrary to the principles of flat design (which I know you are
> opposed to to...).  A general solution would not require boxes or nests,
and
> would allow for the joining of arbitrary axes to each other.  I was
going to
> produce a model, but am too out of it at the moment to work out the
details;
> sorry.
>
>  -E
>
> On Wed, 15 Jun 2022, Marshall Lochbaum wrote:
>
> > It's an interesting transpose, but BQN has a much more elegant
solution:
> > with multidimensional Join, the product of arrays is just ∾a×<b, or
∾×⟜<
> > as a tacit function.
> >
> > Code:
https://mlochbaum.github.io/BQN/try.html#code=YSDihpAgMTArMuKAvzPipYrihpU2CmIg4oaQIDPigL804qWK4oaVMTIK4oi+YcOXPGI=
> >
> > Docs: https://mlochbaum.github.io/BQN/doc/join.html#join
> >
> > J's raze is just like Join for list arguments, but that implicit ravel
> > means it's stuck doing 1-dimensional joins forever. I said in the
> > previous podcast that I really didn't like J's implicit ravel and this
> > is why (and I said I missed its multidimensional i. for example code
> > only... also relevant).
> >
> > Even so, it's nice to know the connection between Join and Transpose.
> > Thanks for the link—I've seen it but it didn't occur to me in this
> > context.
> >
> > Marshall
> >
> > On Wed, Jun 15, 2022 at 09:00:13PM +0200, Jan-Pieter Jacobs wrote:
> > > Hi,
> > >
> > > I'd like to thank the entire Arraycast crew for this excellent
podcast, I'm
> > > always looking forward to the next episode. I find it super
informative,
> > > with a healthy dose of humour. Great job; please continue ;).
> > >
> > > Since you didn't seem to find many applications of dyadic transpose,
I'd
> > > like to point out the Kronecker product page on the J wiki:
> > > https://code.jsoftware.com/wiki/Essays/Kronecker_Product
> > >
> > > Conceptually, it multiplies each element of a left array with the
entirity
> > > of the right array.
> > > One of the implementations (kp) uses dyadic transpose to zip
together the
> > > axes of the *"0 _ in alternating order.
> > >
> > > A while back, I coded up a generalised version for arbitrarily shaped
> > > arrays (that is any but not scalar. see the "kpnd" verb, on the same
page),
> > > using the same approach. I hope this extension makes sense, because
I could
> > > not find any implementation or description of such generalisation.
The "as"
> > > verb calculates the required axis shuffle needed, to be later
reshaped into
> > > the final shape by the "cs" verb.
> > >
> > > As an aside (I didn't put it on the Kronecker product page since
it's not
> > > exactly a Kronecker product), in recent J (903 or up), one can
define a
> > > generic Kronecker-dyad forming adverb as the following tacit
modifier:
> > >
> > > kd =: (("0 _) |:~ as) (]: ($,)~ cs)
> > >
> > > such that kpnd is equivalent to * kd. This way one could do
Kronecker sums
> > > (+kp) or Kronecker versions of whatever rank 0 dyad you'd like.
> > >
> > > Now to find an application for these verbs... Always nice to have a
pretty
> > > solution waiting to meet its corresponding problem :p.
> > >
> > > Best regards,
> > > Jan-Pieter
> > >
> > > On Sat, 11 Jun 2022, 18:21 'robert therriault' via Programming, <
> > > programm...@jsoftware.com> wrote:
> > >
> > > > Hi everyone,
> > > >
> > > > In this episode we explore monadic and dyadic transpose and the
ways it is
> > > > interpreted in APL, BQN and J.
> > > >
> > > > Host: Conor Hoekstra Panel: Marshall Lochbaum, Adám Brudzewsky,
Stephen
> > > > Taylor and Bob Therriault.
> > > >
> > > >
https://www.arraycast.com/episodes/episode28-rank-and-leading-axis-gbbpe
> > > >
> > > > Cheers, bob
> > > >
----------------------------------------------------------------------
> > > > For information about J forums see
http://www.jsoftware.com/forums.htm
> > > >
> > >
----------------------------------------------------------------------
> > > For information about J forums see
http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to