# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/YesnielX/celsius-to-fahrenheit-with-tf/blob/master/celsius-to-fahrenheit.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="61QkNe0yZpRI"
import tensorflow as tf
import numpy as np

# + id="5SIlPF-YZzTm"
a = np.array([10, 30, -50, -10, -15, 5, 25], dtype=float)
b = np.array([50, 86, -58, 14, 5, 41, 77], dtype=float)

# + id="brTOwV8ac9qM"
layer = tf.keras.layers.Dense(units=1, input_shape=[1])
model = tf.keras.Sequential([layer])

# + id="S3StyhE9duA7"
model.compile(optimizer=tf.keras.optimizers.Adam(0.1), loss="mean_squared_error")

# + colab={"base_uri": "https://localhost:8080/"} id="aD2Z9SAYeKW3" outputId="0a37322a-b077-44f4-a9fe-d048ae51439b"
print("Comenzando entrenamiento....")
history = model.fit(a, b, epochs=2000, verbose=False)
print('Entrenamiento finalizado')

# + colab={"base_uri": "https://localhost:8080/", "height": 296} id="EzfApxn6ewI9" outputId="ec871fb4-7e3f-4d3b-f746-58b04d1d96c6"
import matplotlib.pyplot as plt
plt.xlabel("# Epoca")
plt.ylabel("# Perdida")
plt.plot(history.history["loss"])

# + colab={"base_uri": "https://localhost:8080/"} id="epmJLyLLfgya" outputId="07039f94-71a7-4446-dcb9-3915affeb613"
result = model.predict([-45])
print(str(result))

StarcoderdataJupyterScriptsDedupFiltered