import os

def ex1():
    code = '''
# EX1: DEEP NEURAL NETWORK

import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import matplotlib.pyplot as plt

x = np.array([0,1,2,3,4,5], dtype=float)
y = 3*x + 2

model = keras.Sequential([layers.Dense(1, input_shape=[1])])
model.compile(optimizer='adam', loss='mse')

history = model.fit(x, y, epochs=500, verbose=0)

weights = model.layers[0].get_weights()
print("Learned weight (slope):", weights[0][0][0])
print("Learned bias:", weights[1][0])

test_value = np.array([10.0])
prediction = model.predict(test_value)[0][0]
print("Prediction for x=10:", prediction)

plt.plot(history.history['loss'])
plt.xlabel("Epochs")
plt.ylabel("Loss")
plt.title("Training Loss Curve")
plt.show()
'''

    # Create file in current working directory
    file_name = "ex1_deep_neural_network.py"

    with open(file_name, "w") as f:
        f.write(code)

    print(f"File created successfully: {file_name}")