Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,17 +8,17 @@ import matplotlib.pyplot as plt
|
|
8 |
# Streamlit UI
|
9 |
st.title('Celsius to Fahrenheit Conversion with TensorFlow')
|
10 |
|
11 |
-
# Define the model
|
12 |
model = tf.keras.Sequential([
|
13 |
-
tf.keras.layers.Dense(units=1, input_shape=[1])
|
14 |
])
|
15 |
|
16 |
# Set a suitable learning rate and number of epochs
|
17 |
learning_rate = 0.01
|
18 |
epochs = 500
|
19 |
|
20 |
-
# Compile the model with the
|
21 |
-
optimizer = tf.keras.optimizers.
|
22 |
model.compile(optimizer=optimizer, loss='mse')
|
23 |
|
24 |
# Training data (Celsius to Fahrenheit)
|
@@ -31,8 +31,8 @@ input_celsius = st.number_input('Enter Celsius value:', value=0.0, format="%.1f"
|
|
31 |
# Button to train the model and make prediction
|
32 |
if st.button('Train Model and Predict Fahrenheit'):
|
33 |
with st.spinner('Training...'):
|
34 |
-
# Fit the model
|
35 |
-
model.fit(celsius, fahrenheit, epochs=epochs)
|
36 |
st.success('Training completed!')
|
37 |
|
38 |
# Make prediction
|
|
|
8 |
# Streamlit UI
|
9 |
st.title('Celsius to Fahrenheit Conversion with TensorFlow')
|
10 |
|
11 |
+
# Define the model with a different weight initializer
|
12 |
model = tf.keras.Sequential([
|
13 |
+
tf.keras.layers.Dense(units=1, input_shape=[1], kernel_initializer='he_normal')
|
14 |
])
|
15 |
|
16 |
# Set a suitable learning rate and number of epochs
|
17 |
learning_rate = 0.01
|
18 |
epochs = 500
|
19 |
|
20 |
+
# Compile the model with the Adam optimizer and loss function
|
21 |
+
optimizer = tf.keras.optimizers.Adam(learning_rate=learning_rate)
|
22 |
model.compile(optimizer=optimizer, loss='mse')
|
23 |
|
24 |
# Training data (Celsius to Fahrenheit)
|
|
|
31 |
# Button to train the model and make prediction
|
32 |
if st.button('Train Model and Predict Fahrenheit'):
|
33 |
with st.spinner('Training...'):
|
34 |
+
# Fit the model
|
35 |
+
model.fit(celsius, fahrenheit, epochs=epochs, batch_size=4)
|
36 |
st.success('Training completed!')
|
37 |
|
38 |
# Make prediction
|