Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
e6d7c5e9
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e6d7c5e9
编写于
3月 24, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs(mge): fix docstring in loss and dataset
GitOrigin-RevId: 6b566734157eaeaa176f735254ac5e8bba96914f
上级
f91881ff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
36 deletion
+40
-36
python_module/megengine/data/dataset/vision/imagenet.py
python_module/megengine/data/dataset/vision/imagenet.py
+16
-10
python_module/megengine/data/transform/vision/transform.py
python_module/megengine/data/transform/vision/transform.py
+19
-23
python_module/megengine/functional/loss.py
python_module/megengine/functional/loss.py
+5
-3
未找到文件。
python_module/megengine/data/dataset/vision/imagenet.py
浏览文件 @
e6d7c5e9
...
...
@@ -69,20 +69,26 @@ class ImageNet(ImageFolder):
"""
def
__init__
(
self
,
root
:
str
=
None
,
train
:
bool
=
True
,
**
kwargs
):
r
"""initilization
r
"""
initialization:
if ``root`` contains ``self.target_folder`` depent on ``train``:
initialize ImageFolder with target_folder
else:
if all raw files are in ``root``:
parse ``self.target_folder`` from raw files
initialize ImageFolder with ``self.target_folder``
else:
raise error
* if ``root`` contains ``self.target_folder`` depent on ``train``:
* initialize ImageFolder with target_folder
* else:
* if all raw files are in ``root``:
* parse ``self.target_folder`` from raw files
* initialize ImageFolder with ``self.target_folder``
* else:
* raise error
:param root: root directory of imagenet data, if root is ``None``, used default_dataset_root
:param train: if ``True``, load the train split, otherwise load the validation split
:param **kwarg: other keyword arguments for ImageFolder init
"""
# process the root path
...
...
python_module/megengine/data/transform/vision/transform.py
浏览文件 @
e6d7c5e9
...
...
@@ -50,29 +50,25 @@ class VisionTransform(Transform):
:param order: Input type order. Input is a tuple contains different structures,
order is used to specify the order of structures. For example, if your input
is (image, boxes) type, then the order should be ("image", "boxes").
is (image, boxes) type, then the order should be ("image", "boxes").
Current available strings & data type are describe below:
"image":
input image, with shape of (H, W, C)
"coords":
coordinates, with shape of (N, 2)
"boxes":
bounding boxes, with shape of (N, 4), "xyxy" format,
the 1st "xy" represents top left point of a box,
the 2nd "xy" represents right bottom point.
"mask":
map used for segmentation, with shape of (H, W, 1)
"keypoints":
keypoints with shape of (N, K, 3), N for number of instances, and K for number of keypoints in one instance. The first two dimensions
of last axis is coordinate of keypoints and the the 3rd dimension is
the label of keypoints.
"polygons": A sequence contains numpy array, its length is number of instances.
Each numpy array represents polygon coordinate of one instance.
"category": categories for some data type. For example, "image_category"
means category of the input image and "boxes_category" means categories of
bounding boxes.
"info":
information for images such as image shapes and image path.
* "image": input image, with shape of (H, W, C)
* "coords": coordinates, with shape of (N, 2)
* "boxes": bounding boxes, with shape of (N, 4), "xyxy" format,
the 1st "xy" represents top left point of a box,
the 2nd "xy" represents right bottom point.
* "mask": map used for segmentation, with shape of (H, W, 1)
* "keypoints": keypoints with shape of (N, K, 3), N for number of instances,
and K for number of keypoints in one instance. The first two dimensions
of last axis is coordinate of keypoints and the the 3rd dimension is
the label of keypoints.
* "polygons": A sequence contains numpy array, its length is number of instances.
Each numpy array represents polygon coordinate of one instance.
* "category": categories for some data type. For example, "image_category"
means category of the input image and "boxes_category" means categories of
bounding boxes.
* "info": information for images such as image shapes and image path.
You can also customize your data types only if you implement the corresponding
_apply_*() methods, otherwise ``NotImplementedError`` will be raised.
...
...
@@ -356,7 +352,7 @@ class Resize(VisionTransform):
:param output_size: Target size of image, with (height, width) shape.
:param interpolation: Interpolation method. All methods are listed below:
* cv2.INTER_NEAREST – a nearest-neighbor interpolation.
* cv2.INTER_LINEAR – a bilinear interpolation (used by default).
* cv2.INTER_AREA – resampling using pixel area relation.
...
...
python_module/megengine/functional/loss.py
浏览文件 @
e6d7c5e9
...
...
@@ -117,8 +117,8 @@ def cross_entropy(
import numpy as np
from megengine import tensor
import megengine.functional as F
data_shape = (1, 2)
label_shape = (1, )
...
...
@@ -156,8 +156,10 @@ def cross_entropy_with_softmax(
It has better numerical stability compared with sequential calls to :func:`~.softmax` and :func:`~.cross_entropy`.
When using label smoothing, the label distribution is as follows:
.. math::
y^{LS}_{k}=y_{k}\left(1-\alpha\right)+\alpha/K
where :math:`y^{LS}` and :math:`y` are new label distribution and origin label distribution respectively.
k is the index of label distribution. :math:`\alpha` is label_smooth and :math:`K` is the number of classes.
...
...
@@ -197,7 +199,7 @@ def triplet_margin_loss(
Creates a criterion that measures the triplet loss given an input tensors.
.. math::
L(a, p, n) = max\left\{d\left(a_{i},p_{i}\right)-d\left(a_{i}, n_{i}\right)+margin, 0\right\},\
L(a, p, n) = max\left\{d\left(a_{i},p_{i}\right)-d\left(a_{i}, n_{i}\right)+margin, 0\right\},\
d\left(x_{i},y_{i}\right)=\left\|x_{i}-y_{i}\right\|_{p}
:param anchor: The input tensor representing the anchor samples.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录