Blessin commited on
Commit
c38a687
·
verified ·
1 Parent(s): 81505d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -14,8 +14,7 @@ model = tf.keras.Sequential([
14
  ])
15
 
16
  # Compile the model with the Adam optimizer and loss function
17
- optimizer = tf.keras.optimizers.Adam(0.01)
18
- model.compile(optimizer=optimizer, loss='mse')
19
 
20
  # Training data (Celsius to Fahrenheit)
21
  celsius = np.array([-40, -10, 0, 8, 15, 22, 38], dtype=float)
@@ -28,7 +27,7 @@ input_celsius = st.number_input('Enter Celsius value:', value=0.0, format="%.1f"
28
  if st.button('Train Model and Predict Fahrenheit'):
29
  with st.spinner('Training...'):
30
  # Fit the model
31
- model.fit(celsius, fahrenheit, epochs=100)
32
  st.success('Training completed!')
33
 
34
  # Make prediction
@@ -47,3 +46,9 @@ if st.button('Train Model and Predict Fahrenheit'):
47
  plt.ylabel('Fahrenheit')
48
  plt.legend()
49
  st.pyplot(plt)
 
 
 
 
 
 
 
14
  ])
15
 
16
  # Compile the model with the Adam optimizer and loss function
17
+ model.compile(optimizer=tf.keras.optimizers.Adam(0.1), loss='mean_squared_error')
 
18
 
19
  # Training data (Celsius to Fahrenheit)
20
  celsius = np.array([-40, -10, 0, 8, 15, 22, 38], dtype=float)
 
27
  if st.button('Train Model and Predict Fahrenheit'):
28
  with st.spinner('Training...'):
29
  # Fit the model
30
+ history = model.fit(celsius, fahrenheit, epochs=500)
31
  st.success('Training completed!')
32
 
33
  # Make prediction
 
46
  plt.ylabel('Fahrenheit')
47
  plt.legend()
48
  st.pyplot(plt)
49
+
50
+ plt.xlabel('Epoch Number')
51
+ plt.ylabel("Loss Magnitude")
52
+ plt.plot(history.history['loss'])
53
+ plt.legend()
54
+ st.pyplot(plt)