ValueError: Cannot convert a partially known TensorShape to a Tensor: (?, 256)
The problem is inside the sampling functions. I had the same problem and found out the answer in the tutorial here.

my original code is:

def sampling(args):
     z_mean, z_log_sigma = args
     epsilon = K.random_normal(shape=z_mean.shape)
     return z_mean + K.exp(z_log_sigma) * epsilon


with this sampling method, I got the same error with yours.

the codes fixed the problem is:

class Sampling(layers.Layer):
  def call(self, inputs):
    z_mean, z_log_var = inputs
    batch = tf.shape(z_mean)[0]
    dim = tf.shape(z_mean)[1]
    epsilon = tf.keras.backend.random_normal(shape=(batch, dim))
    return z_mean + tf.exp(0.5 * z_log_var) * epsilon


It uses tf.shape to get the required shape parameters. It somehow fixes the problem.