Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
6c827bcc
Commit
6c827bcc
authored
Jun 06, 2019
by
Amir MOHAMMADI
Browse files
improve logging for vat loss
parent
ce97d05e
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/loss/vat.py
View file @
6c827bcc
...
...
@@ -108,20 +108,20 @@ class VATLoss:
architecture
=
partial
(
architecture
,
reuse
=
True
)
with
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
reuse
=
True
):
vat_loss
=
self
.
virtual_adversarial_loss
(
features
,
logits
,
architecture
,
mode
)
tf
.
summary
.
scalar
(
"
vat_
loss"
,
vat_loss
)
tf
.
summary
.
scalar
(
"loss
_VAT
"
,
vat_loss
)
tf
.
add_to_collection
(
tf
.
GraphKeys
.
LOSSES
,
vat_loss
)
if
self
.
method
==
'vat'
:
loss
=
vat_loss
elif
self
.
method
==
'vatent'
:
ent_loss
=
entropy_y_x
(
logits
)
tf
.
summary
.
scalar
(
"entropy
_loss
"
,
ent_loss
)
tf
.
summary
.
scalar
(
"
loss_
entropy"
,
ent_loss
)
tf
.
add_to_collection
(
tf
.
GraphKeys
.
LOSSES
,
ent_loss
)
loss
=
vat_loss
+
ent_loss
else
:
raise
ValueError
return
loss
def
virtual_adversarial_loss
(
self
,
features
,
logits
,
architecture
,
mode
,
name
=
"vat_loss"
):
def
virtual_adversarial_loss
(
self
,
features
,
logits
,
architecture
,
mode
,
name
=
"vat_loss
_op
"
):
r_vadv
=
self
.
generate_virtual_adversarial_perturbation
(
features
,
logits
,
architecture
,
mode
)
logit_p
=
tf
.
stop_gradient
(
logits
)
adversarial_input
=
features
+
r_vadv
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment