0

I am trying to implement this paper. I have to try to interpolate the latent code of an autoencoder, as mentioned in the paper. The latent code is the encoded input of an autoencoder. The shape of the latent code (for two samples) is (2, 64, 64, 128).

This is what I have done:

image1 = sel_train_encodings[0]
image2 = sel_train_encodings[1]

x = image1[:,0,0]
x_new = image2[:,0,0]

new_array = interp1d(x, image1, axis=0, fill_value='extrapolate', kind='linear')(x_new)

I basically took the encodings of two images and tried to interpolate( with extrapolation for some points as all points don't lie in the same range) and then did interpolation over one of the axes. But the results I later obtain with these interpolated values are not so good, am I doing something wrong/how else to do it?

According to one of the given answers, I also tried to do 2D interpolation in the following way:

image1 = sel_train_encodings[0]
image2 = sel_train_encodings[1]

new_array = griddata((x,z),y,(x_new, z_new), method='cubic', fill_value='extrapolate')

But this resulted in the error:

ValueError: shape mismatch: objects cannot be broadcast to a single shape
Ravish Jha
  • 481
  • 3
  • 25

1 Answers1

1

Scipy has a couple of 2D interpolation routines, depending on the spacing of the (x, y):

Sarah Messer
  • 3,592
  • 1
  • 26
  • 43
  • I am not able to use 2D interpolation because the dimensions of `x,y,z` are not the same. I get the following error while using `griddata()` : `shape mismatch: objects cannot be broadcast to a single shape` – Ravish Jha Jan 04 '22 at 18:56
  • Sorry, I was misunderstanding your issue. I should've read more carefully... I think you're going to have to deal with _resampling_, not just _interpolation_. You could also try to make an approximate _analytic_ function (like a polynomial or fft) for each image and then combine those analytically. I haven't read the paper, but presumably the authors talked a bit about the details of their "interpolation" scheme? – Sarah Messer Jan 04 '22 at 22:52