我正在尝试实现一个64x64x3
来将一些图像分类到相应的类。图片大小为CSV
。我的数据集包含25,000张图片以及14 pre-extracted features
文件,其中包含CNN
颜色,长度等文件。
我想构建一个Python
模型,该模型利用图像数据和训练和预测功能。如何使用Keras
在ON DUPLICATE KEY UPDATE
中实现此类模型。?
答案 0 :(得分:1)
我开始假设您可以毫无问题地导入数据,并且您已经将x数据分离为图像和要素,并且您将y数据作为每个图像的标签。
您可以使用keras功能api让神经网络接受多个输入。
from keras.models import Model
from keras.layers import Conv2D, Dense, Input, Embedding, multiply, Reshape, concatenate
img = Input(shape=(64, 64, 3))
features = Input(shape=(14,))
embedded = Embedding(input_dim=14, output_dim=60*32)(features)
embedded = Reshape(target_shape=(14, 60,32))(embedded)
encoded = Conv2D(32, (3, 3), activation='relu')(img)
encoded = Conv2D(32, (3, 3), activation='relu')(encoded)
x = concatenate([embedded, encoded], axis=1)
x = Dense(64, activation='relu')(x)
x = Dense(64, activation='relu')(x)
main_output = Dense(1, activation='sigmoid', name='main_output')(x)
model = Model([img, features], [main_output])