Bernd-Ebenhoch commited on
Commit
a77475c
·
1 Parent(s): 6a2352e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -56,17 +56,17 @@ lr = float(st.text_input('Learning rate', value=0.5))
56
 
57
  prob_A = float(st.text_input('Click probability of ad A', value=0.3))
58
 
59
- prob_B = float(st.text_input('Click probability of ad B', value=0.54
60
 
61
- epochs = int(st.text_input('Number of ad impressions (epochs)', value=1000))
62
 
63
- information_for_plotting = np.zeros((epochs, 10))
64
 
65
  if st.button('Run the ad campaign and display the results'):
66
 
67
  with st.spinner('Simulating the ad campaign may take a few seconds ...'):
68
 
69
- for epoch in range(epochs):
70
 
71
  # The neural network is used to choose the action
72
  # To display the learning progress, we also record the
@@ -98,16 +98,16 @@ if st.button('Run the ad campaign and display the results'):
98
  model.trainable_variables[1].assign(
99
  model.trainable_variables[1]-lr*grads_adjusted[1])
100
 
101
- information_for_plotting[epoch, 0] = output.numpy()[0]
102
- information_for_plotting[epoch, 1] = action.numpy()[0].astype(int)
103
- information_for_plotting[epoch, 2] = loss
104
- information_for_plotting[epoch, 3] = grads[0]
105
- information_for_plotting[epoch, 4] = grads[1]
106
- information_for_plotting[epoch, 5] = reward
107
- information_for_plotting[epoch, 6] = grads_adjusted[0]
108
- information_for_plotting[epoch, 7] = grads_adjusted[1]
109
- information_for_plotting[epoch, 8] = copy.deepcopy(model.trainable_variables[0])
110
- information_for_plotting[epoch, 9] = copy.deepcopy(model.trainable_variables[1])
111
 
112
  # Plot the results
113
  titles = ['Model Output', 'Action', 'Loss', 'Gradients', 'Rewards',
@@ -132,7 +132,7 @@ if st.button('Run the ad campaign and display the results'):
132
  plt.gca().yaxis.set_major_formatter(plt.FormatStrFormatter('%.2f'))
133
  plt.ylabel(titles[i])
134
 
135
- plt.xlabel('Epoch')
136
  plt.show()
137
 
138
  # Sum of the total clicks obtained
 
56
 
57
  prob_A = float(st.text_input('Click probability of ad A', value=0.3))
58
 
59
+ prob_B = float(st.text_input('Click probability of ad B', value=0.4))
60
 
61
+ steps = int(st.text_input('Number of ad impressions (steps)', value=1000))
62
 
63
+ information_for_plotting = np.zeros((steps, 10))
64
 
65
  if st.button('Run the ad campaign and display the results'):
66
 
67
  with st.spinner('Simulating the ad campaign may take a few seconds ...'):
68
 
69
+ for step in range(steps):
70
 
71
  # The neural network is used to choose the action
72
  # To display the learning progress, we also record the
 
98
  model.trainable_variables[1].assign(
99
  model.trainable_variables[1]-lr*grads_adjusted[1])
100
 
101
+ information_for_plotting[step, 0] = output.numpy()[0]
102
+ information_for_plotting[step, 1] = action.numpy()[0].astype(int)
103
+ information_for_plotting[step, 2] = loss
104
+ information_for_plotting[step, 3] = grads[0]
105
+ information_for_plotting[step, 4] = grads[1]
106
+ information_for_plotting[step, 5] = reward
107
+ information_for_plotting[step, 6] = grads_adjusted[0]
108
+ information_for_plotting[step, 7] = grads_adjusted[1]
109
+ information_for_plotting[step, 8] = copy.deepcopy(model.trainable_variables[0])
110
+ information_for_plotting[step, 9] = copy.deepcopy(model.trainable_variables[1])
111
 
112
  # Plot the results
113
  titles = ['Model Output', 'Action', 'Loss', 'Gradients', 'Rewards',
 
132
  plt.gca().yaxis.set_major_formatter(plt.FormatStrFormatter('%.2f'))
133
  plt.ylabel(titles[i])
134
 
135
+ plt.xlabel('Step')
136
  plt.show()
137
 
138
  # Sum of the total clicks obtained