Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
394a34e0
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
286
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
394a34e0
编写于
6月 17, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
6a569885
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
44 deletion
+7
-44
dygraph/datasets/optic_disc_seg.py
dygraph/datasets/optic_disc_seg.py
+0
-4
dygraph/models/unet.py
dygraph/models/unet.py
+4
-8
dygraph/utils/distributed.py
dygraph/utils/distributed.py
+3
-32
未找到文件。
dygraph/datasets/optic_disc_seg.py
浏览文件 @
394a34e0
...
...
@@ -12,13 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
print_function
import
os
import
random
from
paddle.fluid.io
import
Dataset
import
cv2
from
utils.download
import
download_file_and_uncompress
...
...
dygraph/models/unet.py
浏览文件 @
394a34e0
...
...
@@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
paddle.fluid
as
fluid
from
paddle.fluid.dygraph
import
Conv2D
,
BatchNorm
,
Pool2D
...
...
@@ -23,8 +19,8 @@ from paddle.fluid.dygraph import Conv2D, BatchNorm, Pool2D
class
UNet
(
fluid
.
dygraph
.
Layer
):
def
__init__
(
self
,
num_classes
,
ignore_index
=
255
):
super
().
__init__
()
self
.
encode
=
Encoder
()
self
.
decode
=
Decode
()
self
.
encode
=
Unet
Encoder
()
self
.
decode
=
Unet
Decode
()
self
.
get_logit
=
GetLogit
(
64
,
num_classes
)
self
.
ignore_index
=
ignore_index
self
.
EPS
=
1e-5
...
...
@@ -61,7 +57,7 @@ class UNet(fluid.dygraph.Layer):
return
avg_loss
class
Encoder
(
fluid
.
dygraph
.
Layer
):
class
Unet
Encoder
(
fluid
.
dygraph
.
Layer
):
def
__init__
(
self
):
super
().
__init__
()
self
.
double_conv
=
DoubleConv
(
3
,
64
)
...
...
@@ -84,7 +80,7 @@ class Encoder(fluid.dygraph.Layer):
return
x
,
short_cuts
class
Decode
(
fluid
.
dygraph
.
Layer
):
class
Unet
Decode
(
fluid
.
dygraph
.
Layer
):
def
__init__
(
self
):
super
().
__init__
()
self
.
up1
=
Up
(
512
,
256
)
...
...
dygraph/utils/distributed.py
浏览文件 @
394a34e0
...
...
@@ -41,36 +41,8 @@ class DistributedBatchSampler(BatchSampler):
batch indices. Default False.
drop_last(bool): whether drop the last incomplete batch dataset size
is not divisible by the batch size. Default False
Examples:
.. code-block:: python
import numpy as np
from hapi.datasets import MNIST
from hapi.distributed import DistributedBatchSampler
class MnistDataset(MNIST):
def __init__(self, mode, return_label=True):
super(MnistDataset, self).__init__(mode=mode)
self.return_label = return_label
def __getitem__(self, idx):
img = np.reshape(self.images[idx], [1, 28, 28])
if self.return_label:
return img, np.array(self.labels[idx]).astype('int64')
return img,
def __len__(self):
return len(self.images)
train_dataset = MnistDataset(mode='train')
dist_train_dataloader = DistributedBatchSampler(train_dataset, batch_size=64)
for data in dist_train_dataloader:
# do something
break
"""
def
__init__
(
self
,
dataset
,
batch_size
,
shuffle
=
False
,
drop_last
=
False
):
self
.
dataset
=
dataset
...
...
@@ -111,9 +83,8 @@ class DistributedBatchSampler(BatchSampler):
indices
=
indices
[
len
(
indices
)
-
last_batch_size
:]
subsampled_indices
.
extend
(
indices
[
self
.
local_rank
*
last_local_batch_size
:(
self
.
local_rank
+
1
)
*
last_local_batch_size
])
indices
[
self
.
local_rank
*
last_local_batch_size
:
(
self
.
local_rank
+
1
)
*
last_local_batch_size
])
return
subsampled_indices
if
self
.
nranks
>
1
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录