複数サンプルでのローレベル手法
この演習では、複数のサンプルがある場合を想定して、最初の全結合(dense)隠れ層を構築し、ローレベル手法への理解を深めます。モデルは学習済みで、最初の層の重み weights1 とバイアス bias1 が利用可能であるとします。まず、borrower_features テンソルと変数 weights1 の行列積を計算します。borrower_features テンソルには、学歴、婚姻状況、年齢が含まれていることを思い出してください。最後に、products1 + bias1 の各要素にシグモイド関数を適用し、dense1 を得ます。
\(products1 = \begin{bmatrix} 3 & 3 & 23 \\ 2 & 1 & 24 \\ 1 & 1 & 49 \\ 1 & 1 & 49 \\ 2 & 1 & 29 \end{bmatrix} \begin{bmatrix} -0.6 & 0.6 \\ 0.8 & -0.3 \\ -0.09 & -0.08 \end{bmatrix}\)
なお、matmul() と keras() は tensorflow からインポート済みです。
この演習はコースの一部です
Introduction to TensorFlow in Python
演習の手順
- 特徴量テンソルと重みの行列積を取り、
products1を計算します。 - シグモイド活性化関数を使って、
products1 + bias1を変換します。 borrower_features、weights1、bias1、dense1の形状を出力します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Compute the product of borrower_features and weights1
products1 = ____
# Apply a sigmoid activation function to products1 + bias1
dense1 = ____
# Print the shapes of borrower_features, weights1, bias1, and dense1
print('\n shape of borrower_features: ', borrower_features.shape)
print('\n shape of weights1: ', ____.shape)
print('\n shape of bias1: ', ____.shape)
print('\n shape of dense1: ', ____.shape)