2021年3月3日星期三

How to use `model.predict` when the target is one of inputs in tensorflow?

I notice the layer LogisticEndpoint in https://www.tensorflow.org/guide/keras/train_and_evaluate#automatically_setting_apart_a_validation_holdout_set . The document build a model like this :

import numpy as np    inputs = keras.Input(shape=(3,), name="inputs")  targets = keras.Input(shape=(10,), name="targets")  logits = keras.layers.Dense(10)(inputs)  predictions = LogisticEndpoint(name="predictions")(logits, targets)    model = keras.Model(inputs=[inputs, targets], outputs=predictions)  model.compile(optimizer="adam")  # No loss argument!    data = {      "inputs": np.random.random((3, 3)),      "targets": np.random.random((3, 10)),  }  model.fit(data)  

My question is that how to use this model when inference , since we don't know the target when we use model.predict

https://stackoverflow.com/questions/66467450/how-to-use-model-predict-when-the-target-is-one-of-inputs-in-tensorflow March 04, 2021 at 09:50AM

没有评论:

发表评论