Fix temperature equation
This commit is contained in:
parent
853468ef82
commit
7659bd6818
|
@ -294,9 +294,10 @@ class ConfigurableSwitchedResidualGenerator3(nn.Module):
|
||||||
|
|
||||||
def update_for_step(self, step, experiments_path='.'):
|
def update_for_step(self, step, experiments_path='.'):
|
||||||
if self.attentions:
|
if self.attentions:
|
||||||
temp = max(1, int(
|
temp = max(1,
|
||||||
self.init_temperature * (self.final_temperature_step - step) / self.final_temperature_step))
|
1 + self.init_temperature * (self.final_temperature_step - step) / self.final_temperature_step)
|
||||||
if temp == 1 and self.heightened_final_step and self.heightened_final_step != 1:
|
if temp == 1 and self.heightened_final_step and step > self.final_temperature_step and \
|
||||||
|
self.heightened_final_step != 1:
|
||||||
# Once the temperature passes (1) it enters an inverted curve to match the linear curve from above.
|
# Once the temperature passes (1) it enters an inverted curve to match the linear curve from above.
|
||||||
# without this, the attention specificity "spikes" incredibly fast in the last few iterations.
|
# without this, the attention specificity "spikes" incredibly fast in the last few iterations.
|
||||||
h_steps_total = self.heightened_final_step - self.final_temperature_step
|
h_steps_total = self.heightened_final_step - self.final_temperature_step
|
||||||
|
|
|
@ -2,11 +2,21 @@ import onnx
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import time
|
import time
|
||||||
|
|
||||||
model = onnx.load('../results/gen.onnx')
|
init_temperature = 10
|
||||||
|
final_temperature_step = 50
|
||||||
|
heightened_final_step = 90
|
||||||
|
heightened_temp_min = .1
|
||||||
|
|
||||||
outputs = {}
|
for step in range(100):
|
||||||
for n in model.graph.node:
|
temp = max(1, 1 + init_temperature * (final_temperature_step - step) / final_temperature_step)
|
||||||
for o in n.output:
|
if temp == 1 and step > final_temperature_step and heightened_final_step and heightened_final_step != 1:
|
||||||
outputs[o] = n
|
# Once the temperature passes (1) it enters an inverted curve to match the linear curve from above.
|
||||||
|
# without this, the attention specificity "spikes" incredibly fast in the last few iterations.
|
||||||
res = 0
|
h_steps_total = heightened_final_step - final_temperature_step
|
||||||
|
h_steps_current = min(step - final_temperature_step, h_steps_total)
|
||||||
|
# The "gap" will represent the steps that need to be traveled as a linear function.
|
||||||
|
h_gap = 1 / heightened_temp_min
|
||||||
|
temp = h_gap * h_steps_current / h_steps_total
|
||||||
|
# Invert temperature to represent reality on this side of the curve
|
||||||
|
temp = 1 / temp
|
||||||
|
print("%i: %f" % (step, temp))
|
Loading…
Reference in New Issue
Block a user