Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
c44de4b0
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
c44de4b0
编写于
1月 07, 2022
作者:
M
miguelCalado
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed PR folders
上级
011a5804
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
45 addition
and
37 deletion
+45
-37
official/legacy/image_classification/classifier_trainer.py
official/legacy/image_classification/classifier_trainer.py
+2
-0
official/legacy/image_classification/classifier_trainer_test.py
...al/legacy/image_classification/classifier_trainer_test.py
+3
-0
official/legacy/image_classification/configs/configs.py
official/legacy/image_classification/configs/configs.py
+33
-0
official/legacy/image_classification/configs/examples/vgg16/gpu.yaml
...gacy/image_classification/configs/examples/vgg16/gpu.yaml
+0
-0
official/legacy/image_classification/vgg16/__init__.py
official/legacy/image_classification/vgg16/__init__.py
+0
-0
official/legacy/image_classification/vgg16/vgg_config.py
official/legacy/image_classification/vgg16/vgg_config.py
+1
-1
official/legacy/image_classification/vgg16/vgg_model.py
official/legacy/image_classification/vgg16/vgg_model.py
+6
-0
official/vision/image_classification/classifier_trainer.py
official/vision/image_classification/classifier_trainer.py
+0
-2
official/vision/image_classification/classifier_trainer_test.py
...al/vision/image_classification/classifier_trainer_test.py
+0
-3
official/vision/image_classification/configs/configs.py
official/vision/image_classification/configs/configs.py
+0
-31
未找到文件。
official/legacy/image_classification/classifier_trainer.py
浏览文件 @
c44de4b0
...
...
@@ -36,6 +36,7 @@ from official.modeling import hyperparams
from
official.modeling
import
performance
from
official.utils
import
hyperparams_flags
from
official.utils.misc
import
keras_utils
from
official.vision.image_classification.vgg16
import
vgg_model
def
get_models
()
->
Mapping
[
str
,
tf
.
keras
.
Model
]:
...
...
@@ -43,6 +44,7 @@ def get_models() -> Mapping[str, tf.keras.Model]:
return
{
'efficientnet'
:
efficientnet_model
.
EfficientNet
.
from_name
,
'resnet'
:
resnet_model
.
resnet50
,
'vgg'
:
vgg_model
.
vgg16
,
}
...
...
official/legacy/image_classification/classifier_trainer_test.py
浏览文件 @
c44de4b0
...
...
@@ -53,6 +53,7 @@ def distribution_strategy_combinations() -> Iterable[Tuple[Any, ...]]:
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
[
'imagenet'
,
...
...
@@ -149,6 +150,7 @@ class ClassifierTest(tf.test.TestCase, parameterized.TestCase):
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
'imagenet'
,
dtype
=
'float16'
,
...
...
@@ -193,6 +195,7 @@ class ClassifierTest(tf.test.TestCase, parameterized.TestCase):
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
'imagenet'
,
dtype
=
'bfloat16'
,
...
...
official/legacy/image_classification/configs/configs.py
浏览文件 @
c44de4b0
...
...
@@ -24,6 +24,7 @@ from official.legacy.image_classification import dataset_factory
from
official.legacy.image_classification.configs
import
base_configs
from
official.legacy.image_classification.efficientnet
import
efficientnet_config
from
official.legacy.image_classification.resnet
import
resnet_config
from
official.vision.image_classification.vgg16
import
vgg_config
@
dataclasses
.
dataclass
...
...
@@ -92,12 +93,44 @@ class ResNetImagenetConfig(base_configs.ExperimentConfig):
model
:
base_configs
.
ModelConfig
=
resnet_config
.
ResNetModelConfig
()
@
dataclasses
.
dataclass
class
VGGImagenetConfig
(
base_configs
.
ExperimentConfig
):
"""Base configuration to train vgg-16 on ImageNet."""
export
:
base_configs
.
ExportConfig
=
base_configs
.
ExportConfig
()
runtime
:
base_configs
.
RuntimeConfig
=
base_configs
.
RuntimeConfig
()
train_dataset
:
dataset_factory
.
DatasetConfig
=
\
dataset_factory
.
ImageNetConfig
(
split
=
'train'
,
one_hot
=
False
,
mean_subtract
=
True
,
standardize
=
True
)
validation_dataset
:
dataset_factory
.
DatasetConfig
=
\
dataset_factory
.
ImageNetConfig
(
split
=
'validation'
,
one_hot
=
False
,
mean_subtract
=
True
,
standardize
=
True
)
train
:
base_configs
.
TrainConfig
=
base_configs
.
TrainConfig
(
resume_checkpoint
=
True
,
epochs
=
90
,
steps
=
None
,
callbacks
=
base_configs
.
CallbacksConfig
(
enable_checkpoint_and_export
=
True
,
enable_tensorboard
=
True
),
metrics
=
[
'accuracy'
,
'top_5'
],
time_history
=
base_configs
.
TimeHistoryConfig
(
log_steps
=
100
),
tensorboard
=
base_configs
.
TensorBoardConfig
(
track_lr
=
True
,
write_model_weights
=
False
),
set_epoch_loop
=
False
)
evaluation
:
base_configs
.
EvalConfig
=
base_configs
.
EvalConfig
(
epochs_between_evals
=
1
,
steps
=
None
)
model
:
base_configs
.
ModelConfig
=
vgg_config
.
VGGModelConfig
()
def
get_config
(
model
:
str
,
dataset
:
str
)
->
base_configs
.
ExperimentConfig
:
"""Given model and dataset names, return the ExperimentConfig."""
dataset_model_config_map
=
{
'imagenet'
:
{
'efficientnet'
:
EfficientNetImageNetConfig
(),
'resnet'
:
ResNetImagenetConfig
(),
'vgg'
:
VGGImagenetConfig
(),
}
}
try
:
...
...
official/
vision
/image_classification/configs/examples/vgg16/gpu.yaml
→
official/
legacy
/image_classification/configs/examples/vgg16/gpu.yaml
浏览文件 @
c44de4b0
文件已移动
official/
vision
/image_classification/vgg16/__init__.py
→
official/
legacy
/image_classification/vgg16/__init__.py
浏览文件 @
c44de4b0
文件已移动
official/
vision
/image_classification/vgg16/vgg_config.py
→
official/
legacy
/image_classification/vgg16/vgg_config.py
浏览文件 @
c44de4b0
...
...
@@ -49,5 +49,5 @@ class VGGModelConfig(base_configs.ModelConfig):
examples_per_epoch
=
1281167
,
boundaries
=
[
30
,
60
],
warmup_epochs
=
0
,
scale_by_batch_size
=
1.
/
128
.
,
scale_by_batch_size
=
1.
/
256
.
,
multipliers
=
[
0.01
/
256
,
0.001
/
256
,
0.0001
/
256
]))
official/
vision
/image_classification/vgg16/vgg_model.py
→
official/
legacy
/image_classification/vgg16/vgg_model.py
浏览文件 @
c44de4b0
...
...
@@ -174,17 +174,23 @@ def vgg16(num_classes,
x
=
layers
.
Flatten
(
name
=
'flatten'
)(
x
)
x
=
layers
.
Dense
(
4096
,
#kernel_initializer=tf.initializers.random_normal(stddev=0.01),
kernel_regularizer
=
_gen_l2_regularizer
(
use_l2_regularizer
),
#bias_regularizer=_gen_l2_regularizer(use_l2_regularizer),
name
=
'fc1'
)(
x
)
x
=
layers
.
Activation
(
'relu'
)(
x
)
x
=
layers
.
Dropout
(
0.5
)(
x
)
x
=
layers
.
Dense
(
4096
,
#kernel_initializer=tf.initializers.random_normal(stddev=0.01),
kernel_regularizer
=
_gen_l2_regularizer
(
use_l2_regularizer
),
#bias_regularizer=_gen_l2_regularizer(use_l2_regularizer),
name
=
'fc2'
)(
x
)
x
=
layers
.
Activation
(
'relu'
)(
x
)
x
=
layers
.
Dropout
(
0.5
)(
x
)
x
=
layers
.
Dense
(
num_classes
,
#kernel_initializer=tf.initializers.random_normal(stddev=0.01),
kernel_regularizer
=
_gen_l2_regularizer
(
use_l2_regularizer
),
#bias_regularizer=_gen_l2_regularizer(use_l2_regularizer),
name
=
'fc1000'
)(
x
)
# A softmax that is followed by the model loss must be done cannot be done
...
...
official/vision/image_classification/classifier_trainer.py
浏览文件 @
c44de4b0
...
...
@@ -36,7 +36,6 @@ from official.vision.image_classification.configs import configs
from
official.vision.image_classification.efficientnet
import
efficientnet_model
from
official.vision.image_classification.resnet
import
common
from
official.vision.image_classification.resnet
import
resnet_model
from
official.vision.image_classification.vgg16
import
vgg_model
def
get_models
()
->
Mapping
[
str
,
tf
.
keras
.
Model
]:
...
...
@@ -44,7 +43,6 @@ def get_models() -> Mapping[str, tf.keras.Model]:
return
{
'efficientnet'
:
efficientnet_model
.
EfficientNet
.
from_name
,
'resnet'
:
resnet_model
.
resnet50
,
'vgg'
:
vgg_model
.
vgg16
,
}
...
...
official/vision/image_classification/classifier_trainer_test.py
浏览文件 @
c44de4b0
...
...
@@ -53,7 +53,6 @@ def distribution_strategy_combinations() -> Iterable[Tuple[Any, ...]]:
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
[
'imagenet'
,
...
...
@@ -150,7 +149,6 @@ class ClassifierTest(tf.test.TestCase, parameterized.TestCase):
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
'imagenet'
,
dtype
=
'float16'
,
...
...
@@ -195,7 +193,6 @@ class ClassifierTest(tf.test.TestCase, parameterized.TestCase):
model
=
[
'efficientnet'
,
'resnet'
,
'vgg'
,
],
dataset
=
'imagenet'
,
dtype
=
'bfloat16'
,
...
...
official/vision/image_classification/configs/configs.py
浏览文件 @
c44de4b0
...
...
@@ -91,36 +91,6 @@ class ResNetImagenetConfig(base_configs.ExperimentConfig):
epochs_between_evals
=
1
,
steps
=
None
)
model
:
base_configs
.
ModelConfig
=
resnet_config
.
ResNetModelConfig
()
@
dataclasses
.
dataclass
class
VGGImagenetConfig
(
base_configs
.
ExperimentConfig
):
"""Base configuration to train vgg-16 on ImageNet."""
export
:
base_configs
.
ExportConfig
=
base_configs
.
ExportConfig
()
runtime
:
base_configs
.
RuntimeConfig
=
base_configs
.
RuntimeConfig
()
train_dataset
:
dataset_factory
.
DatasetConfig
=
\
dataset_factory
.
ImageNetConfig
(
split
=
'train'
,
one_hot
=
False
,
mean_subtract
=
True
,
standardize
=
True
)
validation_dataset
:
dataset_factory
.
DatasetConfig
=
\
dataset_factory
.
ImageNetConfig
(
split
=
'validation'
,
one_hot
=
False
,
mean_subtract
=
True
,
standardize
=
True
)
train
:
base_configs
.
TrainConfig
=
base_configs
.
TrainConfig
(
resume_checkpoint
=
True
,
epochs
=
90
,
steps
=
None
,
callbacks
=
base_configs
.
CallbacksConfig
(
enable_checkpoint_and_export
=
True
,
enable_tensorboard
=
True
),
metrics
=
[
'accuracy'
,
'top_5'
],
time_history
=
base_configs
.
TimeHistoryConfig
(
log_steps
=
100
),
tensorboard
=
base_configs
.
TensorBoardConfig
(
track_lr
=
True
,
write_model_weights
=
False
),
set_epoch_loop
=
False
)
evaluation
:
base_configs
.
EvalConfig
=
base_configs
.
EvalConfig
(
epochs_between_evals
=
1
,
steps
=
None
)
model
:
base_configs
.
ModelConfig
=
vgg_config
.
VGGModelConfig
()
def
get_config
(
model
:
str
,
dataset
:
str
)
->
base_configs
.
ExperimentConfig
:
"""Given model and dataset names, return the ExperimentConfig."""
...
...
@@ -128,7 +98,6 @@ def get_config(model: str, dataset: str) -> base_configs.ExperimentConfig:
'imagenet'
:
{
'efficientnet'
:
EfficientNetImageNetConfig
(),
'resnet'
:
ResNetImagenetConfig
(),
'vgg'
:
VGGImagenetConfig
()
}
}
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录