Tensorflow probability gives AttributeError: 'Tensor' object has no attribute 'log_prob'

hello, I was trying to use tensorflow probability to train a neural network to learn a multivariate distribution of which I know the covariance matrix but i am getting the error AttributeError: ‘Tensor’ object has no attribute ‘log_prob’

the network is fairly simple ( i just started learning ml):

def NLL(y, distr): 
  return -distr.log_prob(y) 

def multi(params):
  return tfp.distributions.MultivariateNormalTriL(
    loc=params, scale_tril=tf.linalg.cholesky(cov_sne_tot) )
from tensorflow.keras.layers import Dropout
from tensorflow.keras.layers import Input
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Adam

 

def bnn():
    

    inputs = Input(shape=(1,))
    hidden = Dense(200,activation="relu")(inputs)
    hidden = Dropout(0.1)(hidden, training=True)
    hidden = Dense(300,activation="relu")(hidden)
    hidden = Dropout(0.1)(hidden, training=True)
    hidden = Dense(200,activation="relu")(hidden)
    hidden = Dropout(0.1)(hidden, training=True)
    params_mc = Dense(1)(hidden)
    dist_mc = tfp.layers.DistributionLambda(multi, name='multi_exp')(params_mc) 

    modello = Model(inputs=inputs, outputs=params_mc)
    return modello
 test = bnn()
test.compile(Adam(learning_rate=0.02), loss= NLL) 
history = test.fit(x,  y, epochs=5000 , verbose=0,batch_size=1048)

i set batch 1048 because that’s the size of the covariance matrix but i get the error

AttributeError Traceback (most recent call last)

in ()
1 test = bnn()
2 test.compile(Adam(learning_rate=0.02), loss= NLL)
----> 3 history = test.fit(x, y, epochs=5000 , verbose=0,batch_size=1048)
4 plt.plot(history.history[‘loss’])
5 plt.legend([‘loss’])

AttributeError: in user code:

File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function  *
    return step_function(self, iterator)
File "<ipython-input-25-4df93026c962>", line 2, in NLL  *
    return -distr.log_prob(y)

AttributeError: 'Tensor' object has no attribute 'log_prob'

can anybody help me understand what i do wrong?