Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
cf085f79
Commit
cf085f79
authored
Apr 06, 2017
by
Lukasz Kaiser
Committed by
GitHub
Apr 06, 2017
Browse files
Merge pull request #1309 from bousmalis/master
More DSN updates
parents
d6bee2c7
09bc6113
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
52 deletions
+12
-52
domain_adaptation/README.md
domain_adaptation/README.md
+4
-4
domain_adaptation/domain_separation/dsn_eval.py
domain_adaptation/domain_separation/dsn_eval.py
+2
-17
domain_adaptation/domain_separation/dsn_train.py
domain_adaptation/domain_separation/dsn_train.py
+2
-25
domain_adaptation/domain_separation/losses.py
domain_adaptation/domain_separation/losses.py
+4
-6
No files found.
domain_adaptation/README.md
View file @
cf085f79
...
...
@@ -30,16 +30,16 @@ MNIST and MNIST-M:
$ export DSN_DATA_DIR=/your/dir
```
Then you need to build the binaries with Bazel
:
Add models and models/slim to your
`$PYTHONPATH`
:
```
$
bazel build -c opt domain_adaptation/domain_separation/...
$
export PYTHONPATH=$PYTHONPATH:$PWD:$PWD/slim
```
Add models and models/slim to your
`$PYTHONPATH`
:
Then you need to build the binaries with Bazel
:
```
$
export PYTHONPATH=$PYTHONPATH:$PWD:$PWD/slim
$
bazel build -c opt domain_adaptation/domain_separation/...
```
You can then train with the following command:
...
...
domain_adaptation/domain_separation/dsn_eval.py
View file @
cf085f79
...
...
@@ -14,22 +14,7 @@
# ==============================================================================
# pylint: disable=line-too-long
r
"""Evaluation for Domain Separation Networks (DSNs).
To build locally for CPU:
blaze build -c opt --copt=-mavx \
third_party/tensorflow_models/domain_adaptation/domain_separation:dsn_eval
To build locally for GPU:
blaze build -c opt --copt=-mavx --config=cuda_clang \
third_party/tensorflow_models/domain_adaptation/domain_separation:dsn_eval
To run locally:
$
./blaze-bin/third_party/tensorflow_models/domain_adaptation/domain_separation/dsn_eval
\
--alsologtostderr
"""
"""Evaluation for Domain Separation Networks (DSNs)."""
# pylint: enable=line-too-long
import
math
...
...
@@ -57,7 +42,7 @@ tf.app.flags.DEFINE_string(
'eval_dir'
,
'/tmp/da/'
,
'Directory where we should write the tf summaries to.'
)
tf
.
app
.
flags
.
DEFINE_string
(
'dataset_dir'
,
'/cns/ok-d/home/konstantinos/cad_learning/'
,
tf
.
app
.
flags
.
DEFINE_string
(
'dataset_dir'
,
None
,
'The directory where the dataset files are stored.'
)
tf
.
app
.
flags
.
DEFINE_string
(
'dataset'
,
'mnist_m'
,
...
...
domain_adaptation/domain_separation/dsn_train.py
View file @
cf085f79
...
...
@@ -13,30 +13,7 @@
# limitations under the License.
# ==============================================================================
# pylint: disable=line-too-long
r
"""Training for Domain Separation Networks (DSNs).
-- Compile:
$ blaze build -c opt --copt=-mavx --config=cuda \
third_party/tensorflow_models/domain_adaptation/domain_separation:dsn_train
-- Run:
$
./blaze-bin/third_party/tensorflow_models/domain_adaptation/domain_separation/dsn_train
\
--similarity_loss=dann \
--basic_tower=dsn_cropped_linemod \
--source_dataset=pose_synthetic \
--target_dataset=pose_real \
--learning_rate=0.012 \
--alpha_weight=0.26 \
--gamma_weight=0.0115 \
--weight_decay=4e-5 \
--layers_to_regularize=fc3 \
--use_separation \
--alsologtostderr
"""
# pylint: enable=line-too-long
"""Training for Domain Separation Networks (DSNs)."""
from
__future__
import
division
import
tensorflow
as
tf
...
...
@@ -59,7 +36,7 @@ tf.app.flags.DEFINE_string('target_dataset', 'pose_real',
tf
.
app
.
flags
.
DEFINE_string
(
'target_labeled_dataset'
,
'none'
,
'Target dataset to train on.'
)
tf
.
app
.
flags
.
DEFINE_string
(
'dataset_dir'
,
'/cns/ok-d/home/konstantinos/cad_learning/'
,
tf
.
app
.
flags
.
DEFINE_string
(
'dataset_dir'
,
None
,
'The directory where the dataset files are stored.'
)
tf
.
app
.
flags
.
DEFINE_string
(
'master'
,
''
,
...
...
domain_adaptation/domain_separation/losses.py
View file @
cf085f79
...
...
@@ -178,16 +178,14 @@ def dann_loss(source_samples, target_samples, weight, scope=None):
assert_op
=
tf
.
Assert
(
tf
.
is_finite
(
domain_loss
),
[
domain_loss
])
with
tf
.
control_dependencies
([
assert_op
]):
tag_loss
=
'losses/
D
omain
L
oss'
tag_accuracy
=
'losses/
D
omain
A
ccuracy'
tag_loss
=
'losses/
d
omain
_l
oss'
tag_accuracy
=
'losses/
d
omain
_a
ccuracy'
if
scope
:
tag_loss
=
scope
+
tag_loss
tag_accuracy
=
scope
+
tag_accuracy
tf
.
summary
.
scalar
(
tag_loss
,
domain_loss
,
name
=
'domain_loss_summary'
)
tf
.
summary
.
scalar
(
tag_accuracy
,
domain_accuracy
,
name
=
'domain_accuracy_summary'
)
tf
.
summary
.
scalar
(
tag_loss
,
domain_loss
)
tf
.
summary
.
scalar
(
tag_accuracy
,
domain_accuracy
)
return
domain_loss
...
...
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