TransWikia.com

How do I stack copies of a 1D tensor in keras?

Data Science Asked by Contestosis on July 19, 2021

I have a tensor x of shape (5, 1). I would like to stack 10 copies of it so that I get a tensor of shape (5, 10). In a sort, it would look like [x|..|x]. How to do it the keras way? I have tried the Concatenate layer, but I got an error.

Help is welcome!

One Answer

After many troubles with Concatenate, I simply did:

x = Reshape((5, 1))(x)
t = ones((1, 10))
stacked_x = x @ t

Maths help a lot. Should have thought about it earlier.

Answered by Contestosis on July 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP