┏┓ ㅤ┓ ㅤ┏┓ ㅤ┏┓ ㅤ┏┓ ㅤ┓ ㅤ┓ ㅤ┓
┃┫ ㅤ┃ ㅤ┃┫ ㅤ┃┫ ㅤ┃┫ ㅤ┃ ㅤ┃ ㅤ┃
┗┛ ㅤ┻ ㅤ┗┛ ㅤ┗┛ ㅤ┗┛ ㅤ┻ ㅤ┻ ㅤ┻
import tensorflow as tf import numpy as np celsius = np.array([-40, -10, 0, 8, 15, 22, 38], dtype=float) fahrenheit = np.array([-40, 14, 32, 46.4, 59, 71.6, 100.4], dtype=float) layer = tf.keras.layers.Dense(units=1, input_shape=[1]) model = tf.keras.Sequential([layer]) model.compile( optimizer=tf.keras.optimizers.Adam(0.1), loss='mean_squared_error' ) print("Starting training...") history = model.fit(celsius, fahrenheit, epochs=1000, verbose=False) print("Model trained") print("Let's make a prediction!") input_value = 100.0 result = model.predict([input_value]) print("The result of converting " + str(input_value) + " Celsius to Fahrenheit is: " + str(result))