Introduction to TensorFlow in Python
Isaiah Hull
Visiting Associate Professor of Finance, BI Norwegian Business School

tf.ones() may perform poorlyimport tensorflow as tf
# Define 500x500 random normal variable
weights = tf.Variable(tf.random.normal([500, 500]))
# Define 500x500 truncated random normal variable
weights = tf.Variable(tf.random.truncated_normal([500, 500]))
# Define a dense layer with the default initializer
dense = tf.keras.layers.Dense(32, activation='relu')
# Define a dense layer with the zeros initializer
dense = tf.keras.layers.Dense(32, activation='relu',\
kernel_initializer='zeros')




import numpy as np
import tensorflow as tf
# Define input data
inputs = np.array(borrower_features, np.float32)
# Define dense layer 1
dense1 = tf.keras.layers.Dense(32, activation='relu')(inputs)
# Define dense layer 2
dense2 = tf.keras.layers.Dense(16, activation='relu')(dense1)
# Apply dropout operation
dropout1 = tf.keras.layers.Dropout(0.25)(dense2)
# Define output layer
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(dropout1)
Introduction to TensorFlow in Python