<jupyter_start><jupyter_text>Introduction to Deep Learning Live Demos<jupyter_code># (2a + 3b)^2
a = tf.constant(300)
b = tf.constant(100)
tf.pow(tf.add(tf.multiply(2, a), tf.multiply(3, b)), 2)
(2 * 30 + 3 * 10) ** 2
(2 * a + 3 * b) ** 2
bank_data = pd.read_csv("data/bank.csv", sep = ";", true_values = ["yes"], false_values = ["no"])
bank_data
bank_data.shape
plt.hist(bank_data.age, bins = 20)
plt.xlabel("Age")
plt.show()
bank_data.dtypes
bank_data = pd.get_dummies(bank_data)
bank_data.shape
bank_data = bank_data.astype(np.float64)
bank_data.dtypes
attributes = bank_data.drop(["y"], axis = 1)
labels = bank_data["y"]
min_max_scale = lambda col: (col - tf.reduce_min(col)) / (tf.reduce_max(col) - tf.reduce_min(col))
num_columns = attributes.shape[1]
transformed_columns = [min_max_scale(attributes.values[:, i]) for i in range(num_columns)]
bank_data_transformed = tf.stack(transformed_columns, axis = 1)
plt.hist(bank_data_transformed.numpy()[:, 0], bins = 20)
plt.show()
bank_data_transformed.shape
labels = labels.astype(int).values
labels_onehot = tf.one_hot(labels, depth = 2)
logistic_regression = Sequential([
    Input(shape = num_columns),
    Dense(2, activation = "sigmoid")
])
logistic_regression.summary()
logistic_regression.compile(optimizer = "adam", loss = "categorical_crossentropy")
logistic_regression.fit(x = bank_data_transformed, y = labels_onehot, epochs = 10)
logistic_regression.layers[0].kernel
neural_network = Sequential([
    Input(shape = num_columns),
    Dense(30, activation = "relu"),
    Dense(20, activation = "relu"),
    Dense(10, activation = "relu"),
    Dense(2, activation = "sigmoid")
])
neural_network.summary()
neural_network.compile(optimizer = "adam", loss = "categorical_crossentropy")
neural_network.fit(x = bank_data_transformed, y = labels_onehot, epochs = 10)<jupyter_output>Train on 4521 samples
Epoch 1/10
4521/4521 [==============================] - 0s 89us/sample - loss: 0.2056
Epoch 2/10
4521/4521 [==============================] - 0s 82us/sample - loss: 0.2012
Epoch 3/10
4521/4521 [==============================] - 0s 85us/sample - loss: 0.1969
Epoch 4/10
4521/4521 [==============================] - 0s 78us/sample - loss: 0.1925
Epoch 5/10
4521/4521 [==============================] - 0s 77us/sample - loss: 0.1914
Epoch 6/10
4521/4521 [==============================] - 0s 79us/sample - loss: 0.1870
Epoch 7/10
4521/4521 [==============================] - 0s 82us/sample - loss: 0.1822
Epoch 8/10
4521/4521 [==============================] - 0s 77us/sample - loss: 0.1807
Epoch 9/10
4521/4521 [==============================] - 0s 82us/sample - loss: 0.1757
Epoch 10/10
4521/4521 [==============================] - 0s 78us/sample - loss: 0.1741
{'fraction_non_alphanumeric': 0.24724061810154527, 'fraction_numerical': 0.08866813833701251, 'mean_word_length': 5.42789598108747, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '262925', 'license': 'MIT', 'n_tokens_mistral': 1165, 'n_tokens_neox': 968, 'n_words': 205, 'path': 'DeepLearning/01.Intro/Intro to Deep Learning.ipynb', 'repo_name': 'LuGeorgiev/Python-SoftUni', 'size': '2718'}