Skip to content

Commit 8ff6934

Browse files
committed
feedbackk III
1 parent ea1af90 commit 8ff6934

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

research/denoised_smoothing/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

research/denoised_smoothing/models/dncnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def conv_block(x: tf.Tensor, channels: int = 64, ksize: int = 3,
2424
channels,
2525
kernel_size=ksize,
2626
padding=padding,
27-
use_bias=True if bn else False,
27+
use_bias=bn,
2828
kernel_initializer="orthogonal"
2929
)(x)
3030
if bn:

research/denoised_smoothing/scripts/certify.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ def perform_certification_test(base_classifier: tf.keras.Model,
2626
10, sigma)
2727
if not os.path.exists(outfile.split('sigma')[0]):
2828
os.makedirs(outfile.split('sigma')[0])
29-
30-
f = open(outfile, 'w')
31-
print("idx\tlabel\tpredict\tradius\tcorrect\ttime", file=f,
29+
30+
with open(outfile, "w") as f:
31+
print("idx\tlabel\tpredict\tradius\tcorrect\ttime", file=f,
3232
flush=True)
3333
print("idx\tlabel\tpredict\tradius\tcorrect\ttime", flush=True)
34-
f.close()
3534

3635
images, labels = dataset
3736
for i in range(len(images)):
@@ -53,12 +52,11 @@ def perform_certification_test(base_classifier: tf.keras.Model,
5352

5453
time_elapsed = str(
5554
datetime.timedelta(seconds=(after_time - before_time)))
56-
57-
f = open(outfile, 'a')
58-
print("{}\t{}\t{}\t{:.3}\t{}\t{}".format(
59-
i, label, prediction, radius, correct, time_elapsed),
60-
file=f, flush=True)
55+
56+
with open(outfile, "a") as f:
57+
print("{}\t{}\t{}\t{:.3}\t{}\t{}".format(
58+
i, label, prediction, radius, correct, time_elapsed),
59+
file=f, flush=True)
6160
print("{}\t{}\t{}\t{:.3}\t{}\t{}".format(
6261
i, label, prediction, radius, correct, time_elapsed),
6362
flush=True)
64-
f.close()

0 commit comments

Comments
 (0)