Skip to content

Commit fd59286

Browse files
authored
Update explanation.py
fix bugs reported by Trae1ounG
1 parent 258b013 commit fd59286

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Scripts/explanation.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,23 @@ def __init__(self, current_sample, history_samples, model_path, original_score,
3939

4040
def search_proper_input(self):
4141
step = 0 # Current step
42-
while step < self.step:
43-
for i in range(len(self.history_samples)):
44-
42+
for i in range(len(self.history_samples)):
43+
if step <= self.step:
4544
self.new_input = self.history_samples[-(i+1):]
4645
print(len(self.new_input))
4746
model = keras.models.load_model(self.model_path) # Load the Keras model
4847
new_current_score = model.predict(self.new_input,batch_size=1)
4948
current_score = new_current_score [-1]
50-
print("searcheed current score", current_score)
49+
print("searched current score", current_score)
5150
current_delta = abs(current_score - self.original_score)
5251

5352
if current_delta <= self.delta:
5453
return self.new_input # Found proper input
55-
56-
self.step += 1
57-
i *= 2 # Double the value of i
54+
step += 1
55+
i *= 2 # Double the value of i
56+
else:
57+
print("Cannot find the proper input within the max steps")
58+
return self.current_sample # Cannot find proper input
5859

5960
return None # Proper input not found within max_steps
6061

0 commit comments

Comments
 (0)