Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
391f22eb
M
Models
项目概览
曾经的那一瞬间
/
Models
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
391f22eb
编写于
7月 22, 2022
作者:
A
A. Unique TensorFlower
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 462680315
上级
b0a37140
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
13 deletion
+9
-13
official/projects/yt8m/modeling/yt8m_model.py
official/projects/yt8m/modeling/yt8m_model.py
+7
-11
official/projects/yt8m/modeling/yt8m_model_test.py
official/projects/yt8m/modeling/yt8m_model_test.py
+2
-2
未找到文件。
official/projects/yt8m/modeling/yt8m_model.py
浏览文件 @
391f22eb
...
...
@@ -65,12 +65,11 @@ class DbofModel(tf.keras.Model):
norm_epsilon: A `float` added to variance to avoid dividing by zero.
**kwargs: keyword arguments to be passed.
"""
del
num_frames
self
.
_self_setattr_tracking
=
False
self
.
_config_dict
=
{
"input_specs"
:
input_specs
,
"num_classes"
:
num_classes
,
"num_frames"
:
num_frames
,
"params"
:
params
}
self
.
_num_classes
=
num_classes
...
...
@@ -80,26 +79,23 @@ class DbofModel(tf.keras.Model):
self
.
_norm
=
layers
.
experimental
.
SyncBatchNormalization
else
:
self
.
_norm
=
layers
.
BatchNormalization
if
tf
.
keras
.
backend
.
image_data_format
()
==
"channels_last"
:
bn_axis
=
-
1
else
:
bn_axis
=
1
bn_axis
=
-
1
# [batch_size x num_frames x num_features]
feature_size
=
input_specs
.
shape
[
-
1
]
# shape 'excluding' batch_size
model_input
=
tf
.
keras
.
Input
(
shape
=
self
.
_input_specs
.
shape
[
1
:])
reshaped_input
=
tf
.
reshape
(
model_input
,
[
-
1
,
feature_size
])
tf
.
summary
.
histogram
(
"input_hist"
,
model_input
)
input_data
=
model_input
# configure model
if
params
.
add_batch_norm
:
reshaped_input
=
self
.
_norm
(
input_data
=
self
.
_norm
(
axis
=
bn_axis
,
momentum
=
norm_momentum
,
epsilon
=
norm_epsilon
,
name
=
"input_bn"
)(
reshaped_input
)
input_data
)
# activation = reshaped input * cluster weights
if
params
.
cluster_size
>
0
:
...
...
@@ -108,7 +104,7 @@ class DbofModel(tf.keras.Model):
kernel_regularizer
=
kernel_regularizer
,
kernel_initializer
=
tf
.
random_normal_initializer
(
stddev
=
1
/
tf
.
sqrt
(
tf
.
cast
(
feature_size
,
tf
.
float32
))))(
reshaped_input
)
input_data
)
if
params
.
add_batch_norm
:
activation
=
self
.
_norm
(
...
...
@@ -142,7 +138,7 @@ class DbofModel(tf.keras.Model):
pooling_method
=
pooling_method
,
hidden_layer_size
=
params
.
context_gate_cluster_bottleneck_size
,
kernel_regularizer
=
kernel_regularizer
)
activation
=
tf
.
reshape
(
activation
,
[
-
1
,
num_frames
,
params
.
cluster_size
])
activation
=
utils
.
frame_pooling
(
activation
,
params
.
pooling_method
)
# activation = activation * hidden1_weights
...
...
official/projects/yt8m/modeling/yt8m_model_test.py
浏览文件 @
391f22eb
...
...
@@ -34,7 +34,7 @@ class YT8MNetworkTest(parameterized.TestCase, tf.test.TestCase):
num_frames: number of frames.
feature_dims: indicates total dimension size of the features.
"""
input_specs
=
tf
.
keras
.
layers
.
InputSpec
(
shape
=
[
num_frames
,
feature_dims
])
input_specs
=
tf
.
keras
.
layers
.
InputSpec
(
shape
=
[
None
,
None
,
feature_dims
])
num_classes
=
3862
model
=
yt8m_model
.
DbofModel
(
...
...
@@ -44,7 +44,7 @@ class YT8MNetworkTest(parameterized.TestCase, tf.test.TestCase):
input_specs
=
input_specs
)
# batch = 2 -> arbitrary value for test
inputs
=
np
.
random
.
rand
(
2
*
num_frames
,
feature_dims
)
inputs
=
np
.
random
.
rand
(
2
,
num_frames
,
feature_dims
)
logits
=
model
(
inputs
)
self
.
assertAllEqual
([
2
,
num_classes
],
logits
.
numpy
().
shape
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录