Skip to content

The phyloss doesn't pass any gradient to the model parameters #5

@N-Shikamaru

Description

@N-Shikamaru

Hello, I have tried running your code following your article.
However, I found that tensorflow only calculates the gradients based on the MSE part in the combined_loss, meanwhile neglecting the phy_loss term.

For instance, I tried training the model only with the phy_loss: model.compile(loss=phyloss, ...), it will return "ValueError: No gradients provided for any variable, XXXXX".

I also tried tf.GradientTape() to calculated the gradients. The gradients calculated using the phyloss is a list of None value (i.e., [None, None, None, None, None, None, None, None])

with tf.GradientTape() as tape:
    Y_pred = model(trainX)
    #loss = mean_squared_error(trainY, Y_pred)
    #loss = totloss(trainY, Y_pred)
    loss = phyloss(trainY, Y_pred)
grads = tape.gradient(loss, model.trainable_variables)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions