Keras の functional api を勉強し始めたところ、いきなり詰まりました。
以下のコードは特定のユーザーのSNSへの投稿からその人の年齢、性別、所得水準を予測しようとするネットワークです。
その中の、age_prediction = layers.Dense(1, name='age')(x) の部分がなぜひとつ前のレイヤにうまくつながるのかがわかりません。
このレイヤの入力に指定している x が複数あってどれに繋げばいいのかよくわからないように思えるのですが、、、
とても初歩的な話なのだと思いますが、どなたか説明よろしくお願いします。
ソースコード
python
1from keras import layers 2from keras import Input 3from keras import Model 4 5vocabulary_size = 50000 6num_income_groups = 10 7 8posts_input = Input(shape=(None,), dtype='int32', name='posts') 9embedded_posts = layers.Embedding(256, vocabulary_size)(posts_input) 10x = layers.Conv1D(128, 5, activation='relu')(embedded_posts) 11x = layers.MaxPooling1D(5)(x) 12x = layers.Conv1D(256, 5, activation='relu')(x) 13x = layers.Conv1D(256, 5, activation='relu')(x) 14x = layers.MaxPooling1D(5)(x) 15x = layers.Conv1D(256, 5, activation='relu')(x) 16x = layers.Conv1D(256, 5, activation='relu')(x) 17x = layers.GlobalMaxPooling1D()(x) 18x = layers.Dense(128, activation='relu')(x) 19 20age_prediction = layers.Dense(1, name='age')(x) 21income_prediction = layers.Dense(num_income_groups, activation='softmax', name='income')(x) 22gender_prediction = layers.Dense(1, activation='sigmoid', name='gender')(x) 23model = Model(posts_input, [age_prediction, income_prediction, gender_prediction])
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/16 05:25