Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
dc97aa0f
M
Models
项目概览
曾经的那一瞬间
/
Models
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc97aa0f
编写于
4月 03, 2017
作者:
N
Neal Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upgrade to TF 1.0
上级
9333e607
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
18 deletion
+20
-18
domain_adaptation/domain_separation/dsn.py
domain_adaptation/domain_separation/dsn.py
+6
-4
domain_adaptation/domain_separation/dsn_test.py
domain_adaptation/domain_separation/dsn_test.py
+1
-1
domain_adaptation/domain_separation/losses.py
domain_adaptation/domain_separation/losses.py
+7
-7
domain_adaptation/domain_separation/models_test.py
domain_adaptation/domain_separation/models_test.py
+1
-1
domain_adaptation/domain_separation/utils.py
domain_adaptation/domain_separation/utils.py
+5
-5
未找到文件。
domain_adaptation/domain_separation/dsn.py
浏览文件 @
dc97aa0f
...
...
@@ -282,15 +282,17 @@ def add_autoencoders(source_data, source_shared, target_data, target_shared,
# Add summaries
source_reconstructions
=
tf
.
concat
(
map
(
normalize_images
,
[
axis
=
2
,
values
=
map
(
normalize_images
,
[
source_data
,
source_recons
,
source_shared_recons
,
source_private_recons
])
,
2
)
]))
target_reconstructions
=
tf
.
concat
(
map
(
normalize_images
,
[
axis
=
2
,
values
=
map
(
normalize_images
,
[
target_data
,
target_recons
,
target_shared_recons
,
target_private_recons
])
,
2
)
]))
tf
.
summary
.
image
(
'Source Images:Recons:RGB'
,
source_reconstructions
[:,
:,
:,
:
3
],
...
...
domain_adaptation/domain_separation/dsn_test.py
浏览文件 @
dc97aa0f
...
...
@@ -26,7 +26,7 @@ class HelperFunctionsTest(tf.test.TestCase):
with
self
.
test_session
()
as
sess
:
# Test for when global_step < domain_separation_startpoint
step
=
tf
.
contrib
.
slim
.
get_or_create_global_step
()
sess
.
run
(
tf
.
initialize_all_variables
())
# global_step = 0
sess
.
run
(
tf
.
global_variables_initializer
())
# global_step = 0
params
=
{
'domain_separation_startpoint'
:
2
}
weight
=
dsn
.
dsn_loss_coefficient
(
params
)
weight_np
=
sess
.
run
(
weight
)
...
...
domain_adaptation/domain_separation/losses.py
浏览文件 @
dc97aa0f
...
...
@@ -100,7 +100,7 @@ def mmd_loss(source_samples, target_samples, weight, scope=None):
tag
=
'MMD Loss'
if
scope
:
tag
=
scope
+
tag
tf
.
contrib
.
deprecated
.
scalar_summary
(
tag
,
loss_value
)
tf
.
summary
.
scalar
(
tag
,
loss_value
)
tf
.
losses
.
add_loss
(
loss_value
)
return
loss_value
...
...
@@ -135,7 +135,7 @@ def correlation_loss(source_samples, target_samples, weight, scope=None):
tag
=
'Correlation Loss'
if
scope
:
tag
=
scope
+
tag
tf
.
contrib
.
deprecated
.
scalar_summary
(
tag
,
corr_loss
)
tf
.
summary
.
scalar
(
tag
,
corr_loss
)
tf
.
losses
.
add_loss
(
corr_loss
)
return
corr_loss
...
...
@@ -155,11 +155,11 @@ def dann_loss(source_samples, target_samples, weight, scope=None):
"""
with
tf
.
variable_scope
(
'dann'
):
batch_size
=
tf
.
shape
(
source_samples
)[
0
]
samples
=
tf
.
concat
(
[
source_samples
,
target_samples
],
0
)
samples
=
tf
.
concat
(
axis
=
0
,
values
=
[
source_samples
,
target_samples
]
)
samples
=
slim
.
flatten
(
samples
)
domain_selection_mask
=
tf
.
concat
(
[
tf
.
zeros
((
batch_size
,
1
)),
tf
.
ones
((
batch_size
,
1
))],
0
)
axis
=
0
,
values
=
[
tf
.
zeros
((
batch_size
,
1
)),
tf
.
ones
((
batch_size
,
1
))]
)
# Perform the gradient reversal and be careful with the shape.
grl
=
grl_ops
.
gradient_reversal
(
samples
)
...
...
@@ -184,9 +184,9 @@ def dann_loss(source_samples, target_samples, weight, scope=None):
tag_loss
=
scope
+
tag_loss
tag_accuracy
=
scope
+
tag_accuracy
tf
.
contrib
.
deprecated
.
scalar_summary
(
tf
.
summary
.
scalar
(
tag_loss
,
domain_loss
,
name
=
'domain_loss_summary'
)
tf
.
contrib
.
deprecated
.
scalar_summary
(
tf
.
summary
.
scalar
(
tag_accuracy
,
domain_accuracy
,
name
=
'domain_accuracy_summary'
)
return
domain_loss
...
...
@@ -216,7 +216,7 @@ def difference_loss(private_samples, shared_samples, weight=1.0, name=''):
cost
=
tf
.
reduce_mean
(
tf
.
square
(
correlation_matrix
))
*
weight
cost
=
tf
.
where
(
cost
>
0
,
cost
,
0
,
name
=
'value'
)
tf
.
contrib
.
deprecated
.
scalar_summary
(
'losses/Difference Loss {}'
.
format
(
name
),
tf
.
summary
.
scalar
(
'losses/Difference Loss {}'
.
format
(
name
),
cost
)
assert_op
=
tf
.
Assert
(
tf
.
is_finite
(
cost
),
[
cost
])
with
tf
.
control_dependencies
([
assert_op
]):
...
...
domain_adaptation/domain_separation/models_test.py
浏览文件 @
dc97aa0f
...
...
@@ -115,7 +115,7 @@ class DecoderTest(tf.test.TestCase):
width
=
width
,
channels
=
channels
,
batch_norm_params
=
batch_norm_params
)
sess
.
run
(
tf
.
initialize_all_variables
())
sess
.
run
(
tf
.
global_variables_initializer
())
output_np
=
sess
.
run
(
output
)
self
.
assertEqual
(
output_np
.
shape
,
(
32
,
height
,
width
,
channels
))
self
.
assertTrue
(
np
.
any
(
output_np
))
...
...
domain_adaptation/domain_separation/utils.py
浏览文件 @
dc97aa0f
...
...
@@ -75,15 +75,15 @@ def reshape_feature_maps(features_tensor):
num_filters
)
num_filters_sqrt
=
int
(
num_filters_sqrt
)
conv_summary
=
tf
.
unstack
(
features_tensor
,
axis
=
3
)
conv_one_row
=
tf
.
concat
(
conv_summary
[
0
:
num_filters_sqrt
],
2
)
conv_one_row
=
tf
.
concat
(
axis
=
2
,
values
=
conv_summary
[
0
:
num_filters_sqrt
]
)
ind
=
1
conv_final
=
conv_one_row
for
ind
in
range
(
1
,
num_filters_sqrt
):
conv_one_row
=
tf
.
concat
(
conv_summary
[
ind
*
num_filters_sqrt
+
0
:
ind
*
num_filters_sqrt
+
num_filters_sqrt
],
2
)
conv_one_row
=
tf
.
concat
(
axis
=
2
,
values
=
conv_summary
[
ind
*
num_filters_sqrt
+
0
:
ind
*
num_filters_sqrt
+
num_filters_sqrt
]
)
conv_final
=
tf
.
concat
(
[
tf
.
squeeze
(
conv_final
),
tf
.
squeeze
(
conv_one_row
)],
1
)
axis
=
1
,
values
=
[
tf
.
squeeze
(
conv_final
),
tf
.
squeeze
(
conv_one_row
)]
)
conv_final
=
tf
.
expand_dims
(
conv_final
,
-
1
)
return
conv_final
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录