02-01-2017, 06:44 AM
def run_once(self, inputs):
if len(inputs) == self.width:
pre_threshold = [inputs[index] * self.input_weights[index] + dot_product(self.internal_weights[index], self.output) + self.biases[index] for index in range(self.width)]
self.output = [1 if pre_threshold[index] > self.thresholds[index] else 0 for index in range(self.width)]
return list(self.output)
else:
print("invalid input lengths")
def stochastic_run(self, probabilities, bitlength):
inputs = [list(i) for i in zip(*[gen_prob(prob, bitlength, True) for prob in probabilities])]
outputs = zip(*[self.run_once(inputs[index]) for index in range(len(inputs))])
output_probs = [eval_prob(out_i) for out_i in outputs]
return output_probs #returns the probability of encountering a 1
if len(inputs) == self.width:
pre_threshold = [inputs[index] * self.input_weights[index] + dot_product(self.internal_weights[index], self.output) + self.biases[index] for index in range(self.width)]
self.output = [1 if pre_threshold[index] > self.thresholds[index] else 0 for index in range(self.width)]
return list(self.output)
else:
print("invalid input lengths")
def stochastic_run(self, probabilities, bitlength):
inputs = [list(i) for i in zip(*[gen_prob(prob, bitlength, True) for prob in probabilities])]
outputs = zip(*[self.run_once(inputs[index]) for index in range(len(inputs))])
output_probs = [eval_prob(out_i) for out_i in outputs]
return output_probs #returns the probability of encountering a 1