我会尝试为Keras预训练模型更改通道

我得到了一个Xception模型。

Xception = tf.keras.applications.Xception(input_shape=(512, 512, 3), include_top=False)

我已经组合了模型以将输入通道更改为3。

input_layer = keras.Input(shape=(512, 512, 1), name="img_input")x = layers.UpSampling3D(size=(1, 1, 3), name="output")(input_layer)input_model = keras.Model(input_layer, x, name="input_model")model = keras.Model(input_model, Xception, name="model")

然而,我遇到了错误

Input tensors to a Functional must come from `tf.keras.Input`. Received: <tensorflow.python.keras.engine.functional.Functional object at 0x7f922942a690> (missing previous layer metadata).

回答:

你只需要以正确的方式将Xception嵌入到你的新模型中:

Xception = tf.keras.applications.Xception(input_shape=(512, 512, 3), include_top=False)input_layer = tf.keras.Input(shape=(512, 512, 1), name="img_input")x = tf.keras.layers.UpSampling3D(size=(1, 1, 3), name="upsampling")(input_layer)output = Xception(x)model = tf.keras.Model(input_layer, output, name="model")

我们创建一个新的Input层,然后进行上采样,最后将所有内容传递给Xception

这里是有运行笔记本,如果你感兴趣的话

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注