画像+画像+値を入力とし、画像にコンボルーション+プーリングを行い、結果を線形変換するニューラルネットを作りたいと考えています。私はケラスでそれをすることはできますか?ノンスタンダード入力のニューラルネット
答えて
これはアーキテクチャクレイグリーの回答に似ていますが、画像、画像、値の形式で、VGG16、ちょうどバニラCNNを使用していません。これらは3つの別々のネットワークで、個々に処理された後に出力が連結され、結果として連結されたベクトルはすべての入力からの情報を含む最終層を通過します。
input_1 = Input(data_1.shape[1:], name = 'input_1')
conv_branch_1 = Conv2D(filters, (kernel_size, kernel_size),
activation = LeakyReLU())(conv_branch_1)
conv_branch_1 = MaxPooling2D(pool_size = (2,2))(conv_branch_1)
conv_branch_1 = Flatten()(conv_branch_1)
input_2 = Input(data_2.shape[1:], name = 'input_2')
conv_branch_2 = Conv2D(filters, (kernel_size, kernel_size),
activation = LeakyReLU())(conv_branch_2)
conv_branch_2 = MaxPooling2D(pool_size = (2,2))(conv_branch_2)
conv_branch_2 = Flatten()(conv_branch_2)
value_input = Input(value_data.shape[1:], name = 'value_input')
fc_branch = Dense(80, activation=LeakyReLU())(value_input)
merged_branches = concatenate([conv_branch_1, conv_branch_2, fc_branch])
merged_branches = Dense(60, activation=LeakyReLU())(merged_branches)
merged_branches = Dropout(0.25)(merged_branches)
merged_branches = Dense(30, activation=LeakyReLU())(merged_branches)
merged_branches = Dense(1, activation='sigmoid')(merged_branches)
model = Model(inputs=[input_1, input_2, value_input], outputs=[merged_branches])
#if binary classification do this otherwise whatever loss you need
model.compile(loss='binary_crossentropy')
、あなたのようnumpy
で2枚の画像を組み合わせることができます(3、幅、高さ)画像の形状があり、あなたのイメージは、RGBタイプであると仮定します。唯一の私たち、このように2枚の画像を組み合わせて
import numpy as np
from PIL import Image
img1 = Image.open('image1.jpg')
img2 = Image.open('imgae2.jpg')
img1 = img1.resize((width,height))
img2 = img2.resize((width,height))
img1_arr = np.asarray(img1,dtype='int32')
img2_arr = np.asarray(img2,dtype='int32')
#shape of img_arr is (width,height,6)
img_arr = np.concatenate((img1_arr,img2_arr),axis=2)
チャンネルを増やすので、最初の2つの軸でコンボリューションを行うことができます。
UPDATE: 私はあなたが、あなたがKerasはconcatenate()
はそれを行うことができます持って、畳み込みの後に2枚の画像をマージするマルチタスクモデルを意味すると思います。
input_tensor = Input(shape=(channels, img_width, img_height))
# Task1 on image1
conv_model1 = VGG16(input_tensor=input_tensor, weights=None, include_top=False, classes=classes,
input_shape=(channels, img_width, img_height))
conv_output1 = conv_model1.output
flatten1 = Flatten()(conv_output1)
# Task2 on image2
conv_model2 = VGG16(input_tensor=input_tensor, weights=None, include_top=False, classes=classes,
input_shape=(channels, img_width, img_height))
conv_output2 = conv_model2.output
flatten2 = Flatten()(conv_output2)
# Merge the output
merged = concatenate([conv_output1, conv_output2], axis=1)
merged = Dense(classes,activation='softmax')(merged)
# add some Dense layers and Dropout,
final_model = Model(inputs=[input_tensor,input_tensor],outputs=merged)
ありがとうございましたが、いずれの画像でも私の畳み込みに異なる重みを付けたいと思います。だから、私はそれが、最終的に接続されているより多くの種類の異なるレイヤーであることを望みます。 – UpmostScarab
もう一度、お返事ありがとうございます。 convolutionBoyは、私が持っていたかったものに近いものでした(したがって名前)。 – UpmostScarab
- 1. さまざまなプロパティを持つ入力用ニューラルネットのモデリング
- 2. TensorFlowニューラルネットの出力の線形関数
- 3. ニューラルネットの設定
- 4. Deeplearning4jニューラルネットの設定
- 5. ニューラルネットのKerasモデルload_weights
- 6. テンソルフローの基本ニューラルネット
- 7. ニューラルネットの逐次トレーニング
- 8. ルビー用ニューラルネット
- 9. 強化学習:ニューラルネット
- 10. ニューラルネットへの公式のエラー
- 11. ニューラルネットとROCRパッケージを使用してニューラルネット曲線をプロット
- 12. 基本ニューラルネットの予測?
- 13. ニューラルネット関数の式パラメータ
- 14. Tensorflow:賢明2つの入力Tensorflowを持つ単純なニューラルネットを想定し1
- 15. ニューラルネット - 各ミニバッチのデータの選択
- 16. ニューラルネットで起こることMatlabのバックプロパゲーション
- 17. 単語予測:ニューラルネット対nグラムのアプローチ
- 18. 非常に深いニューラルネットのトレーニングエラー
- 19. Reception Inception V3 Conv 0%精度のニューラルネット(テンソルフロー)
- 20. JavaScript入力値の入力
- 21. ニューラルネット最適化遺伝的アルゴリズム
- 22. MxNetニューラルネットは学習しません
- 23. PHPの入力での入力
- 24. ブートストラップ2.0.2 - 入力の余白の入力
- 25. WPFアプリケーションでのマウス入力の入力
- 26. ストリームセットへのスパークストリーミング入力の入力
- 27. Play Frameworkでの入力の入力
- 28. 入力テキストのhtml5入力ボックスのスピナー?
- 29. TestNGへの入力の入力
- 30. モデルへの合成入力の入力
画像の順序と数は固定されていますか? –
@ Craig.Liはい、ちょうど2 – UpmostScarab