0
$\begingroup$

I have two tensors:

a.shape = (1, 30, 1220) # represents text embedding vector (30 spans, each with embedding size of 1220)
b.shape = (1, 128, 256) # represents image features obtained from a pretrained CNN
  1. How do I concatenate everything in b to each one of the 30 spans of a?

  2. How to concatenate the whole b to the whole a?

$\endgroup$
0
$\begingroup$

You can't concatenate these two arrays, because their shapes don't match. You could concatenate them if you had:

1)

    a.shape = (1, 30, 1220)
    b.shape = (1, 30, 256)
    a.shape = (1, 30, 1220)
    b.shape = (1, 128, 1220)

or eventually

3)

    a.shape = (1, 30, 1220)
    b.shape = (1, 128, 30)
    a.shape = (1, 30, 1220)
    b.shape = (1, 1220, 256)
$\endgroup$
1
  • $\begingroup$ Can I flatten the image feature vector and then concatenate with text feature vector? $\endgroup$
    – Sid
    Sep 3 at 1:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.