Python 将InputLayer添加到现有Keras模型以与Android Tensor流库一起使用

Python 将InputLayer添加到现有Keras模型以与Android Tensor流库一起使用,python,machine-learning,tensorflow,keras,image-recognition,Python,Machine Learning,Tensorflow,Keras,Image Recognition,我对keras和TensorFlow很陌生 当尝试将Keras模型(在新的iOS IA框架上正确编译和工作)转换为tensorflow模型以在Android中使用时,我缺少输入节点 因此,我试图在我的模型中添加一个InputLayer,但没有成功 我得到的错误如下(每次运行时,占位符编号不同…): 这是我的代码代码,这是我的代码,修改的部分与工作的KERAS模型相比,修改的部分相对于工作的部分,修改的部分相对于工作的部分,修改的部分,修改的部分,修改的部分与工作的部分,与工作的KERAS模型相比

我对keras和TensorFlow很陌生

当尝试将Keras模型(在新的iOS IA框架上正确编译和工作)转换为tensorflow模型以在Android中使用时,我缺少输入节点

因此,我试图在我的模型中添加一个InputLayer,但没有成功

我得到的错误如下(每次运行时,占位符编号不同…):

这是我的代码代码,这是我的代码,修改的部分与工作的KERAS模型相比,修改的部分相对于工作的部分,修改的部分相对于工作的部分,修改的部分,修改的部分,修改的部分与工作的部分,与工作的KERAS模型相比,修改的部分,修改的部分与工作的部分相比,修改的部分与工作的部分相比,与工作的部分相比,修改的部分与工作的部分相比,修改的部分与工作的部分的部分部分部分,与工作的部分相比,与工作的部分的部分部分相比,与工作的部分部分相比,修改的部分相比,修改的部分的部分的部分的部分相比,与工作的部分部分的部分相比,修改的部分的部分与工作的部分的部分相比,与工作的部分的部分的部分的部分相比,与工作的部分相比,修改的部分的部分的部分的部分的部分相比,与工作的部分相比,修改的部分的部分的部分的部分相比,与工作的部分的部分的部分的部分相比,与工作的部分相比,与######


使用kerasapi,您不必使用张量来输入数据

首先设置展平的输入形状:

# Start construction of the Keras Sequential model.
model = Sequential()

# Add an input layer which is similar to a feed_dict in TensorFlow.
# Note that the input-shape must be a tuple containing the image-size.
model.add(InputLayer(input_shape=(3*img_width*img_height)))

# Add the real shape that conv layer spect
model.add(Reshape((img_width,img_height , 3)))
然后训练网络将图像作为numpy数组传递,这与scikitlearn类似

# Note that train_datagen and train_labels must be numpy array object
model.fit(x=train_datagen,
          y=train_labels,
          epochs=1, batch_size=128)

每次在tf模型中使用占位符时,都需要传递一个提要。我没有看到你提供一个训练/适应方法。
# Start construction of the Keras Sequential model.
model = Sequential()

# Add an input layer which is similar to a feed_dict in TensorFlow.
# Note that the input-shape must be a tuple containing the image-size.
model.add(InputLayer(input_shape=(3*img_width*img_height)))

# Add the real shape that conv layer spect
model.add(Reshape((img_width,img_height , 3)))
# Note that train_datagen and train_labels must be numpy array object
model.fit(x=train_datagen,
          y=train_labels,
          epochs=1, batch_size=128)