Commit 218796ed by Ting PAN

Remove the deprecated DALI API

Summary:
This commit removes the deprecated API for DALI 0.24.
Besides, variable length keyword arguments are added for forward compatibility.
1 parent c40eaf7b
Showing with 807 additions and 643 deletions
......@@ -21,6 +21,7 @@ from dragon.vm.caffe.core.solver import AdamSolver
from dragon.vm.caffe.core.solver import NesterovSolver
from dragon.vm.caffe.core.solver import RMSPropSolver
from dragon.vm.caffe.core.solver import SGDSolver
from dragon.vm.caffe.core.solver import Solver
# Functions
from dragon.vm.caffe.core.net_spec import to_proto
......
......@@ -8,7 +8,7 @@
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
"""The solver to update parameters."""
"""The solver to optimize parameters."""
from __future__ import absolute_import
from __future__ import division
......@@ -28,7 +28,7 @@ from dragon.vm.caffe.core.proto import caffe_pb2
class Solver(object):
"""The abstraction ``caffe.Solver``."""
"""The base solver class to optimize parameters."""
def __init__(self, solver_file, is_root=True):
"""Create a ``Solver``.
......@@ -330,7 +330,7 @@ class AdamSolver(Solver):
momentum=0.9,
momentum2=0.999,
delta=1e-8,
)
}
```
"""
......@@ -397,7 +397,7 @@ class RMSPropSolver(Solver):
base_lr=0.01,
rms_decay=0.99,
delta=1e-8,
)
}
```
"""
......@@ -430,13 +430,13 @@ class SGDSolver(Solver):
solver {
base_lr=0.01,
momentum=0.9,
)
}
```
"""
def __init__(self, solver_file, is_root=True):
"""Create a `SGDSolver``.
"""Create a ``SGDSolver``.
Parameters
----------
......
......@@ -12,7 +12,7 @@ if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
/wd4003 /wd4114
/wd4244 /wd4251 /wd4273 /wd4275
/wd4244 /wd4251 /wd4267 /wd4273 /wd4275
/wd4800 /wd4819 /wd4996")
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
......
......@@ -22,32 +22,32 @@ import sys as _sys
from dragon.vm.dali._api import ops
# Classes
from dragon.vm.dali.core.iterator import Iterator
from dragon.vm.dali.core.pipeline import Pipeline
from dragon.vm.dali.core.framework.iterator import Iterator
from dragon.vm.dali.core.framework.pipeline import Pipeline
# Functions
from dragon.vm.dali.core.context import device
from dragon.vm.dali.core.context import get_device_type
from dragon.vm.dali.core.context import get_distributed_info
from dragon.vm.dali.core.framework.context import device
from dragon.vm.dali.core.framework.context import get_device_type
from dragon.vm.dali.core.framework.context import get_distributed_info
# Enums
from dragon.vm.dali.core.types import BOOL
from dragon.vm.dali.core.types import BGR
from dragon.vm.dali.core.types import FLOAT
from dragon.vm.dali.core.types import FLOAT32
from dragon.vm.dali.core.types import FLOAT64
from dragon.vm.dali.core.types import INT8
from dragon.vm.dali.core.types import INT32
from dragon.vm.dali.core.types import INT64
from dragon.vm.dali.core.types import INTERP_TRIANGULAR
from dragon.vm.dali.core.types import NCHW
from dragon.vm.dali.core.types import NHWC
from dragon.vm.dali.core.types import RGB
from dragon.vm.dali.core.types import STRING
from dragon.vm.dali.core.types import UINT8
from dragon.vm.dali.core.types import UINT16
from dragon.vm.dali.core.types import UINT32
from dragon.vm.dali.core.types import UINT64
from dragon.vm.dali.core.framework.types import BOOL
from dragon.vm.dali.core.framework.types import BGR
from dragon.vm.dali.core.framework.types import FLOAT
from dragon.vm.dali.core.framework.types import FLOAT32
from dragon.vm.dali.core.framework.types import FLOAT64
from dragon.vm.dali.core.framework.types import INT8
from dragon.vm.dali.core.framework.types import INT32
from dragon.vm.dali.core.framework.types import INT64
from dragon.vm.dali.core.framework.types import INTERP_TRIANGULAR
from dragon.vm.dali.core.framework.types import NCHW
from dragon.vm.dali.core.framework.types import NHWC
from dragon.vm.dali.core.framework.types import RGB
from dragon.vm.dali.core.framework.types import STRING
from dragon.vm.dali.core.framework.types import UINT8
from dragon.vm.dali.core.framework.types import UINT16
from dragon.vm.dali.core.framework.types import UINT32
from dragon.vm.dali.core.framework.types import UINT64
# Attributes
_API_MODULE = ops
......
......@@ -13,24 +13,24 @@ from __future__ import absolute_import as _absolute_import
from __future__ import division as _division
from __future__ import print_function as _print_function
from dragon.vm.dali.core.ops.array import Cast
from dragon.vm.dali.core.ops.array import Pad
from dragon.vm.dali.core.ops.array import Reshape
from dragon.vm.dali.core.ops.builtin import ExternalSource
from dragon.vm.dali.core.ops.color import BrightnessContrast
from dragon.vm.dali.core.ops.color import Hsv
from dragon.vm.dali.core.ops.crop import RandomBBoxCrop
from dragon.vm.dali.core.ops.crop import Slice
from dragon.vm.dali.core.ops.decoder import ImageDecoder
from dragon.vm.dali.core.ops.decoder import ImageDecoderRandomCrop
from dragon.vm.dali.core.ops.fused import CropMirrorNormalize
from dragon.vm.dali.core.ops.geometric import BbFlip
from dragon.vm.dali.core.ops.paste import BBoxPaste
from dragon.vm.dali.core.ops.paste import Paste
from dragon.vm.dali.core.ops.random import CoinFlip
from dragon.vm.dali.core.ops.random import Uniform
from dragon.vm.dali.core.ops.reader import KPLRecordReader
from dragon.vm.dali.core.ops.reader import TFRecordReader
from dragon.vm.dali.core.ops.resize import Resize
from dragon.vm.dali.core.ops.bbox_ops import BbFlip
from dragon.vm.dali.core.ops.bbox_ops import BBoxPaste
from dragon.vm.dali.core.ops.builtin_ops import ExternalSource
from dragon.vm.dali.core.ops.decoder_ops import ImageDecoder
from dragon.vm.dali.core.ops.decoder_ops import ImageDecoderRandomCrop
from dragon.vm.dali.core.ops.generic_ops import Cast
from dragon.vm.dali.core.ops.generic_ops import Pad
from dragon.vm.dali.core.ops.generic_ops import Reshape
from dragon.vm.dali.core.ops.generic_ops import Slice
from dragon.vm.dali.core.ops.image_ops import BrightnessContrast
from dragon.vm.dali.core.ops.image_ops import CropMirrorNormalize
from dragon.vm.dali.core.ops.image_ops import Hsv
from dragon.vm.dali.core.ops.image_ops import Paste
from dragon.vm.dali.core.ops.image_ops import RandomBBoxCrop
from dragon.vm.dali.core.ops.image_ops import Resize
from dragon.vm.dali.core.ops.random_ops import CoinFlip
from dragon.vm.dali.core.ops.random_ops import Uniform
from dragon.vm.dali.core.ops.reader_ops import KPLRecordReader
from dragon.vm.dali.core.ops.reader_ops import TFRecordReader
__all__ = [_s for _s in dir() if not _s.startswith('_')]
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
......@@ -26,7 +26,7 @@ from dragon.core.device import cuda
from dragon.core.eager.tensor import EagerTensor
from dragon.core.framework import device_spec
from dragon.core.framework import workspace
from dragon.vm.dali.core import types
from dragon.vm.dali.core.framework import types
class Iterator(object):
......
......@@ -15,7 +15,7 @@ from __future__ import print_function
try:
from nvidia.dali import pipeline
from dragon.vm.dali.core import context
from dragon.vm.dali.core.framework import context
class Pipeline(pipeline.Pipeline):
"""The base pipeline class to define operations.
......@@ -151,6 +151,8 @@ except ImportError:
"""
self._batch_size = batch_size
self._num_threads = num_threads
self._seed = seed
self._prefetch_queue_depth = prefetch_queue_depth
@property
def batch_size(self):
......
......@@ -16,85 +16,65 @@ from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
from dragon.vm.dali.core import context
from dragon.vm.dali.core.framework import context
class BBoxPaste(object):
"""Transform bounding boxes to match the ``Paste`` operator.
class BbFlip(object):
"""Flip the bounding boxes.
Examples:
```python
bbox_paste = dali.ops.BBoxPaste()
paste_pos = dali.ops.Uniform((0., 1.))
paste_ratio = dali.ops.Uniform((0., 3.))
paste_prob = dali.ops.CoinFlip(0.5)
bbox_flip = dali.ops.BbFlip()
flip_rng = dali.ops.CoinFlip(0.5)
bbox = bbox_flip(inputs['bbox'], horizontal=flip_rng())
```
bbox = bbox_paste(
inputs['bbox'],
# Expand ratio
ratio=paste_ratio() * paste_prob() + 1.,
# PosX, PosY
paste_x=paste_pos(),
paste_y=paste_pos(),
)
"""
def __new__(
cls,
ltrb=True,
ratio=None,
paste_x=None,
paste_y=None,
):
"""Create a ``BBoxPaste`` operator.
def __new__(cls, horizontal=None, vertical=None, ltrb=True, **kwargs):
"""Create a ``BbFlip`` operator.
Parameters
----------
horizontal : int, optional
Whether to apply the horizontal flip.
vertical : int, optional
Whether to apply the vertical flip.
ltrb : bool, optional, default=True
Indicate the bbox is ``ltrb`` or ``xywh`` format.
ratio : int, optional
The expand ratio.
paste_x : int, optional
The paste position at x-axis.
paste_y : int, optional
The paste position at y-axis.
Returns
-------
nvidia.dali.ops.BBoxPaste
nvidia.dali.ops.BbFlip
The operator.
"""
return ops.BBoxPaste(
return ops.BbFlip(
horizontal=horizontal,
vertical=vertical,
ltrb=ltrb,
ratio=ratio,
paste_x=paste_x,
paste_y=paste_y,
device='cpu',
device=context.get_device_type(),
**kwargs
)
class Paste(object):
"""Copy image into a larger canvas.
class BBoxPaste(object):
"""Transform bounding boxes to match the ``Paste`` operator.
Examples:
```python
paste = dali.ops.Paste(
# The image channels
n_channels=3,
# Historical values before mean subtraction
fill_value=(102., 115., 122.),
)
bbox_paste = dali.ops.BBoxPaste()
paste_pos = dali.ops.Uniform((0., 1.))
paste_ratio = dali.ops.Uniform((0., 3.))
paste_prob = dali.ops.CoinFlip(0.5)
y = paste(
inputs['x'],
bbox = bbox_paste(
inputs['bbox'],
# Expand ratio
ratio=paste_ratio() * paste_prob() + 1.,
# PosX, PosY
......@@ -107,20 +87,18 @@ class Paste(object):
def __new__(
cls,
n_channels=3,
fill_value=(0., 0., 0.),
ltrb=True,
ratio=None,
paste_x=None,
paste_y=None,
**kwargs
):
"""Create a ``Paste`` operator.
"""Create a ``BBoxPaste`` operator.
Parameters
----------
n_channels : int, optional, default=3
The image channels.
fill_value : Sequence[number], optional
The value(s) to fill for the canvas.
ltrb : bool, optional, default=True
Indicate the bbox is ``ltrb`` or ``xywh`` format.
ratio : int, optional
The expand ratio.
paste_x : int, optional
......@@ -130,15 +108,15 @@ class Paste(object):
Returns
-------
nvidia.dali.ops.Paste
nvidia.dali.ops.BBoxPaste
The operator.
"""
return ops.Paste(
n_channels=n_channels,
fill_value=fill_value,
return ops.BBoxPaste(
ltrb=ltrb,
ratio=ratio,
paste_x=paste_x,
paste_y=paste_y,
device=context.get_device_type(),
device='cpu',
**kwargs
)
......@@ -16,9 +16,10 @@ from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
from dragon.vm.dali.core import context
from dragon.vm.dali.core.framework import context
class ExternalSource(object):
......@@ -42,7 +43,7 @@ class ExternalSource(object):
"""
def __new__(cls):
def __new__(cls, **kwargs):
"""Create a ``ExternalSource`` operator.
Returns
......@@ -51,4 +52,4 @@ class ExternalSource(object):
The operator.
"""
return ops.ExternalSource(device=context.get_device_type())
return ops.ExternalSource(device=context.get_device_type(), **kwargs)
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.vm.dali.core import context
class BrightnessContrast(object):
"""Adjust the brightness and contrast.
Examples:
```python
# Historical jitter range for brightness and contrast
twist_rng = dali.ops.Uniform(range=[0.6, 1.4])
bc = dali.ops.BrightnessContrast()
y = bc(inputs['x'], brightness=twist_rng(), contrast=twist_rng())
```
"""
def __new__(cls):
"""Create a ``BrightnessContrastBrightnessContrast`` operator.
Returns
-------
nvidia.dali.ops.BrightnessContrast
The operator.
"""
return ops.BrightnessContrast(device=context.get_device_type())
class Hsv(object):
"""Adjust the hue and saturation.
Examples:
```python
# Historical jitter range for saturation
twist_rng = dali.ops.Uniform(range=[0.6, 1.4])
hsv = dali.ops.Hsv()
y = hsv(inputs['x'], saturation=twist_rng())
```
"""
def __new__(cls):
"""Create a ``Hsv`` operator.
Returns
-------
nvidia.dali.ops.Hsv
The operator.
"""
return ops.Hsv(device=context.get_device_type())
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.vm.dali.core import context
class RandomBBoxCrop(object):
"""Return a valid crop restricted by bounding boxes.
Examples:
```python
bbox_crop = dali.ops.RandomBBoxCrop(
# Range of scale
scaling=[0.3, 1.0],
# Range of aspect ratio
aspect_ratio=[0.5, 2.0],
# Minimum IoUs to satisfy
thresholds=[0.0, 0.1, 0.3, 0.5, 0.7, 0.9],
)
crop_begin, crop_size, bbox, label = bbox_crop(inputs['bbox'], inputs['label'])
```
"""
def __new__(
cls,
scaling=(0.3, 1.0),
aspect_ratio=(0.5, 2.0),
thresholds=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9),
allow_no_crop=True,
ltrb=True,
num_attempts=10,
):
"""Create a ``RandomBBoxCrop`` operator.
Parameters
----------
scaling : Sequence[float], optional, default=(0.3, 1.0)
The range of scale for sampling regions.
aspect_ratio : Sequence[float], optional, default=(0.5, 2.0)
The range of aspect ratio for sampling regions.
thresholds : Sequence[float], optional
The minimum IoU(s) to satisfy.
allow_no_crop : bool, optional, default=True
**True** to include the no-cropping as a option.
ltrb : bool, optional, default=True
Indicate the bbox is ``ltrb`` or ``xywh`` format.
num_attempts : int, optional, default=10
The max number of sampling trails.
Returns
-------
nvidia.dali.ops.RandomBBoxCrop
The operator.
"""
return ops.RandomBBoxCrop(
scaling=scaling,
aspect_ratio=aspect_ratio,
thresholds=thresholds,
allow_no_crop=allow_no_crop,
ltrb=ltrb,
num_attempts=num_attempts,
device='cpu',
)
class Slice(object):
"""Select an interval of elements from input.
Examples:
```python
slice = dali.ops.Slice(
# Axis of intervals
axes=[1, 0],
# Whether the begin of interval is normalized
# in a range of [0.0, 1.0]
normalized_anchor=True,
# Whether the size of interval is normalized
# in a range of [0.0, 1.0]
normalized_shape=True,
)
y = slice(inputs['x'], crop_begin, crop_size)
```
"""
def __new__(
cls,
axes=(1, 0),
normalized_anchor=True,
normalized_shape=True,
):
"""Create a ``Slice`` operator.
Parameters
----------
axes : Sequence[int], optional
The axis to select.
normalized_anchor : bool, optional, default=True
Whether the begin of interval is normalized.
normalized_shape : bool, optional, default=True
Whether the size of interval is normalized.
Returns
-------
nvidia.dali.ops.Slice
The operator.
"""
return ops.Slice(
axes=axes,
normalized_anchor=normalized_anchor,
device=context.get_device_type(),
)
......@@ -16,11 +16,12 @@ from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
from dragon.core.util import six
from dragon.vm.dali.core import context
from dragon.vm.dali.core import types
from dragon.vm.dali.core.framework import context
from dragon.vm.dali.core.framework import types
class ImageDecoder(object):
......@@ -40,6 +41,7 @@ class ImageDecoder(object):
output_type='BGR',
host_memory_padding=8388608,
device_memory_padding=16777216,
**kwargs
):
"""Create a ``ImageDecoder`` operator.
......@@ -65,6 +67,7 @@ class ImageDecoder(object):
host_memory_padding=host_memory_padding,
device_memory_padding=device_memory_padding,
device=context.get_device_type(mixed=True),
**kwargs
)
......@@ -93,6 +96,7 @@ class ImageDecoderRandomCrop(object):
random_area=(0.08, 1.),
random_aspect_ratio=(0.75, 1.33),
num_attempts=10,
**kwargs
):
"""Create a ``ImageDecoderRandomCrop`` operator.
......@@ -127,4 +131,5 @@ class ImageDecoderRandomCrop(object):
random_aspect_ratio=random_aspect_ratio,
num_attempts=num_attempts,
device=context.get_device_type(mixed=True),
**kwargs
)
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import six
from dragon.vm.dali.core import context
from dragon.vm.dali.core import types
class CropMirrorNormalize(object):
"""Crop and normalize input with the horizontal flip.
Examples:
```python
flip_rng = dali.ops.CoinFlip(0.5)
cmn = dali.ops.CropMirrorNormalize(
# Match the number of spatial dims
# (H, W) for 2d input
# (D, H, W) for 3d input
crop=(224, 224),
# Historical values to normalize input
mean=(102., 115., 122.),
std=(1., 1., 1.),
# ``BGR``, ``RGB``, or ``GRAY``
image_type='BGR',
# Or ``float16`` for fp16 training
output_dtype='float32',
# Or ``NHWC``
output_layout='NCHW'
)
y = cmn(inputs['x'], mirror=flip_rng())
```
"""
def __new__(
cls,
crop=None,
mirror=None,
mean=0.,
std=1.,
image_type='BGR',
output_dtype='float32',
output_layout='NCHW',
):
"""Create a ``CropMirrorNormalize`` operator.
Parameters
----------
crop : Sequence[int], optional
The cropped spatial dimensions for output.
mirror : {0, 1}, optional
Whether to apply the horizontal flip.
mean : Union[float, Sequence[float]], optional
The values to subtract.
std : Union[float, Sequence[float]], optional
The values to divide after subtraction.
image_type : {'BGR', 'RGB'}, optional
The color space of input.
output_dtype : {'float16', 'float32'}, optional
The data type of output.
output_layout : {'NCHW', 'NHWC'}, optional
The data format of output.
Returns
-------
nvidia.dali.ops.CropMirrorNormalize
The operator.
"""
if isinstance(output_dtype, six.string_types):
output_dtype = getattr(types, output_dtype.upper())
if isinstance(output_layout, six.string_types):
output_layout = getattr(types, output_layout.upper())
if isinstance(image_type, six.string_types):
image_type = getattr(types, image_type.upper())
return ops.CropMirrorNormalize(
crop=crop,
mirror=mirror,
mean=mean,
std=std,
output_dtype=output_dtype,
output_layout=output_layout,
image_type=image_type,
device=context.get_device_type(),
)
......@@ -16,11 +16,12 @@ from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
from dragon.core.util import six
from dragon.vm.dali.core import context
from dragon.vm.dali.core import types
from dragon.vm.dali.core.framework import context
from dragon.vm.dali.core.framework import types
class Cast(object):
......@@ -35,7 +36,7 @@ class Cast(object):
"""
def __new__(cls, dtype):
def __new__(cls, dtype, **kwargs):
"""Create a ``Cast`` operator.
Parameters
......@@ -54,6 +55,7 @@ class Cast(object):
return ops.Cast(
dtype=dtype,
device=context.get_device_type(),
**kwargs
)
......@@ -74,7 +76,7 @@ class Pad(object):
"""
def __new__(cls, axes=(0, 1), fill_value=0., align=None):
def __new__(cls, axes=(0, 1), fill_value=0., align=None, **kwargs):
"""Create a ``Pad`` operator.
Parameters
......@@ -97,6 +99,7 @@ class Pad(object):
fill_value=fill_value,
align=align,
device=context.get_device_type(),
**kwargs
)
......@@ -117,7 +120,7 @@ class Reshape(object):
"""
def __new__(cls, shape=None):
def __new__(cls, shape=None, **kwargs):
"""Create a ``Reshape`` operator.
Parameters
......@@ -134,4 +137,59 @@ class Reshape(object):
return ops.Reshape(
shape=shape,
device=context.get_device_type(),
**kwargs
)
class Slice(object):
"""Select an interval of elements from input.
Examples:
```python
slice = dali.ops.Slice(
# Axis of intervals
axes=[1, 0],
# Whether the begin of interval is normalized
# in a range of [0.0, 1.0]
normalized_anchor=True,
# Whether the size of interval is normalized
# in a range of [0.0, 1.0]
normalized_shape=True,
)
y = slice(inputs['x'], crop_begin, crop_size)
```
"""
def __new__(
cls,
axes=(1, 0),
normalized_anchor=True,
normalized_shape=True,
**kwargs
):
"""Create a ``Slice`` operator.
Parameters
----------
axes : Sequence[int], optional
The axis to select.
normalized_anchor : bool, optional, default=True
Whether the begin of interval is normalized.
normalized_shape : bool, optional, default=True
Whether the size of interval is normalized.
Returns
-------
nvidia.dali.ops.Slice
The operator.
"""
return ops.Slice(
axes=axes,
normalized_anchor=normalized_anchor,
device=context.get_device_type(),
**kwargs
)
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.vm.dali.core import context
class BbFlip(object):
"""Flip the bounding boxes.
Examples:
```python
bbox_flip = dali.ops.BbFlip()
flip_rng = dali.ops.CoinFlip(0.5)
bbox = bbox_flip(inputs['bbox'], horizontal=flip_rng())
```
"""
def __new__(cls, horizontal=None, vertical=None, ltrb=True):
"""Create a ``BbFlip`` operator.
Parameters
----------
horizontal : int, optional
Whether to apply the horizontal flip.
vertical : int, optional
Whether to apply the vertical flip.
ltrb : bool, optional, default=True
Indicate the bbox is ``ltrb`` or ``xywh`` format.
Returns
-------
nvidia.dali.ops.BbFlip
The operator.
"""
return ops.BbFlip(
horizontal=horizontal,
vertical=vertical,
ltrb=ltrb,
device=context.get_device_type(),
)
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
from dragon.core.util import six
from dragon.vm.dali.core.framework import context
from dragon.vm.dali.core.framework import types
class BrightnessContrast(object):
"""Adjust the brightness and contrast of image.
Examples:
```python
# Historical jitter range for brightness and contrast
twist_rng = dali.ops.Uniform(range=[0.6, 1.4])
bc = dali.ops.BrightnessContrast()
y = bc(inputs['x'], brightness=twist_rng(), contrast=twist_rng())
```
"""
def __new__(cls, **kwargs):
"""Create a ``BrightnessContrastBrightnessContrast`` operator.
Returns
-------
nvidia.dali.ops.BrightnessContrast
The operator.
"""
return ops.BrightnessContrast(device=context.get_device_type(), **kwargs)
class CropMirrorNormalize(object):
"""Crop and normalize image with the horizontal flip.
Examples:
```python
flip_rng = dali.ops.CoinFlip(0.5)
cmn = dali.ops.CropMirrorNormalize(
# Match the number of spatial dims
# (H, W) for 2d input
# (D, H, W) for 3d input
crop=(224, 224),
# Historical values to normalize input
mean=(102., 115., 122.),
std=(1., 1., 1.),
# Or ``float16`` for fp16 training
dtype='float32',
# Or ``NHWC``
output_layout='NCHW'
)
y = cmn(inputs['x'], mirror=flip_rng())
```
"""
def __new__(
cls,
crop=None,
mirror=None,
mean=0.,
std=1.,
dtype='float32',
output_layout='NCHW',
**kwargs
):
"""Create a ``CropMirrorNormalize`` operator.
Parameters
----------
crop : Sequence[int], optional
The cropped spatial dimensions for output.
mirror : {0, 1}, optional
Whether to apply the horizontal flip.
mean : Union[float, Sequence[float]], optional
The values to subtract.
std : Union[float, Sequence[float]], optional
The values to divide after subtraction.
dtype : {'float16', 'float32'}, optional
The data type of output.
output_layout : {'NCHW', 'NHWC'}, optional
The data format of output.
Returns
-------
nvidia.dali.ops.CropMirrorNormalize
The operator.
"""
if isinstance(dtype, six.string_types):
dtype = getattr(types, dtype.upper())
if isinstance(output_layout, six.string_types):
output_layout = getattr(types, output_layout.upper())
return ops.CropMirrorNormalize(
crop=crop,
mirror=mirror,
mean=mean,
std=std,
dtype=dtype,
output_layout=output_layout,
device=context.get_device_type(),
**kwargs
)
class Hsv(object):
"""Adjust the hue and saturation.
Examples:
```python
# Historical jitter range for saturation
twist_rng = dali.ops.Uniform(range=[0.6, 1.4])
hsv = dali.ops.Hsv()
y = hsv(inputs['x'], saturation=twist_rng())
```
"""
def __new__(cls, **kwargs):
"""Create a ``Hsv`` operator.
Returns
-------
nvidia.dali.ops.Hsv
The operator.
"""
return ops.Hsv(device=context.get_device_type(), **kwargs)
class Paste(object):
"""Copy image into a larger canvas.
Examples:
```python
paste = dali.ops.Paste(
# The image channels
n_channels=3,
# Historical values before mean subtraction
fill_value=(102., 115., 122.),
)
paste_pos = dali.ops.Uniform((0., 1.))
paste_ratio = dali.ops.Uniform((0., 3.))
paste_prob = dali.ops.CoinFlip(0.5)
y = paste(
inputs['x'],
# Expand ratio
ratio=paste_ratio() * paste_prob() + 1.,
# PosX, PosY
paste_x=paste_pos(),
paste_y=paste_pos(),
)
```
"""
def __new__(
cls,
n_channels=3,
fill_value=(0., 0., 0.),
ratio=None,
paste_x=None,
paste_y=None,
**kwargs
):
"""Create a ``Paste`` operator.
Parameters
----------
n_channels : int, optional, default=3
The image channels.
fill_value : Sequence[number], optional
The value(s) to fill for the canvas.
ratio : int, optional
The expand ratio.
paste_x : int, optional
The paste position at x-axis.
paste_y : int, optional
The paste position at y-axis.
Returns
-------
nvidia.dali.ops.Paste
The operator.
"""
return ops.Paste(
n_channels=n_channels,
fill_value=fill_value,
ratio=ratio,
paste_x=paste_x,
paste_y=paste_y,
device=context.get_device_type(),
**kwargs
)
class RandomBBoxCrop(object):
"""Return an valid image crop restricted by bounding boxes.
Examples:
```python
bbox_crop = dali.ops.RandomBBoxCrop(
# Range of scale
scaling=[0.3, 1.0],
# Range of aspect ratio
aspect_ratio=[0.5, 2.0],
# Minimum IoUs to satisfy
thresholds=[0.0, 0.1, 0.3, 0.5, 0.7, 0.9],
)
crop_begin, crop_size, bbox, label = bbox_crop(inputs['bbox'], inputs['label'])
```
"""
def __new__(
cls,
scaling=(0.3, 1.0),
aspect_ratio=(0.5, 2.0),
thresholds=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9),
allow_no_crop=True,
ltrb=True,
num_attempts=10,
**kwargs
):
"""Create a ``RandomBBoxCrop`` operator.
Parameters
----------
scaling : Sequence[float], optional, default=(0.3, 1.0)
The range of scale for sampling regions.
aspect_ratio : Sequence[float], optional, default=(0.5, 2.0)
The range of aspect ratio for sampling regions.
thresholds : Sequence[float], optional
The minimum IoU(s) to satisfy.
allow_no_crop : bool, optional, default=True
**True** to include the no-cropping as a option.
ltrb : bool, optional, default=True
Indicate the bbox is ``ltrb`` or ``xywh`` format.
num_attempts : int, optional, default=10
The max number of sampling trails.
Returns
-------
nvidia.dali.ops.RandomBBoxCrop
The operator.
"""
return ops.RandomBBoxCrop(
scaling=scaling,
aspect_ratio=aspect_ratio,
thresholds=thresholds,
allow_no_crop=allow_no_crop,
ltrb=ltrb,
num_attempts=num_attempts,
device='cpu',
**kwargs
)
class Resize(object):
"""Resize the image.
Examples:
```python
# Resize to a fixed area
resize1 = dali.ops.Resize(resize_x=300, resize_y=300)
# Resize along the shorter side
resize2 = dali.ops.Resize(resize_shorter=600, max_size=1000)
# Resize along the longer side
resize3 = dali.ops.Resize(resize_longer=512)
```
"""
def __new__(
cls,
resize_x=None,
resize_y=None,
resize_shorter=None,
resize_longer=None,
max_size=None,
interp_type='TRIANGULAR',
):
"""Create a ``Resize`` operator.
Parameters
----------
resize_x : int, optional
The output image width.
resize_y : int, optional
The output image height.
resize_shorter : int, optional
Resize along the shorter side and limited by ``max_size``.
resize_longer : int, optional
Resize along the longer side.
max_size : int, optional, default=0
The limited size for ``resize_shorter``.
interp_type : {'NN', 'LINEAR', 'TRIANGULAR', 'CUBIC', 'GAUSSIAN', 'LANCZOS3'}, optional
The interpolation method.
"""
if isinstance(interp_type, six.string_types):
interp_type = getattr(types, 'INTERP_' + interp_type.upper())
return ops.Resize(
resize_x=resize_x,
resize_y=resize_y,
resize_shorter=resize_shorter,
resize_longer=resize_longer,
max_size=max_size,
interp_type=interp_type,
device=context.get_device_type(),
)
......@@ -16,7 +16,8 @@ from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import deprecation
ops = deprecation.not_installed('nvidia.dali')
class CoinFlip(object):
......@@ -31,7 +32,7 @@ class CoinFlip(object):
"""
def __new__(cls, probability=0.5):
def __new__(cls, probability=0.5, **kwargs):
"""Create a ``CoinFlip`` operator.
Parameters
......@@ -45,11 +46,11 @@ class CoinFlip(object):
The operator.
"""
return ops.CoinFlip(probability=probability)
return ops.CoinFlip(probability=probability, **kwargs)
class Uniform(object):
"""Sample values from a uniform distribution.
"""Sample values from an uniform distribution.
Examples:
......@@ -60,7 +61,7 @@ class Uniform(object):
"""
def __new__(cls, range=(-1., 1.)):
def __new__(cls, range=(-1., 1.), **kwargs):
"""Create an ``Uniform`` operator.
Parameters
......@@ -74,4 +75,4 @@ class Uniform(object):
The operator.
"""
return ops.Uniform(range=range)
return ops.Uniform(range=range, **kwargs)
......@@ -19,16 +19,16 @@ import os
try:
from nvidia.dali import ops
from nvidia.dali import tfrecord as tfrec
from nvidia.dali import tfrecord
except ImportError:
from dragon.core.util import deprecation
ops = deprecation.NotInstalled('nvidia.dali')
tfrec = deprecation.NotInstalled('nvidia.dali')
tfrecord = deprecation.NotInstalled('nvidia.dali')
from dragon.core.io import reader
from dragon.core.io import kpl_record
from dragon.vm.dali.core import context
from dragon.vm.dali.core.ops.builtin import ExternalSource
from dragon.vm.dali.core.framework import context
from dragon.vm.dali.core.ops.builtin_ops import ExternalSource
class KPLRecordReader(object):
......@@ -73,6 +73,7 @@ class KPLRecordReader(object):
num_shards=1,
shuffle_after_epoch=False,
shuffle_chunks=0,
**kwargs
):
"""Create a ``KPLRecordReader``.
......@@ -100,6 +101,7 @@ class KPLRecordReader(object):
num_parts=num_shards,
shuffle=shuffle_after_epoch,
num_chunks=shuffle_chunks,
**kwargs
)
self._buffer = self._reader.q_out = mp.Queue(
self._prefetch_depth * self._batch_size)
......@@ -186,6 +188,7 @@ class TFRecordReader(object):
num_shards=1,
random_shuffle=False,
initial_fill=1024,
**kwargs
):
"""Create a ``TFRecordReader``.
......@@ -217,6 +220,7 @@ class TFRecordReader(object):
features=features,
random_shuffle=random_shuffle,
initial_fill=initial_fill,
**kwargs
)
@staticmethod
......@@ -232,7 +236,10 @@ class TFRecordReader(object):
if features_file is None:
raise FileNotFoundError('File <FEATURES> is missing.')
with open(os.path.join(path, features_file), 'r') as f:
features = eval(f.read().replace('tf.', 'tfrec.'))
features = f.read()
features = features.replace('tf.', 'tfrecord.')
features = features.replace('tf.io.', 'tfrecord.')
features = eval(features)
data_files.sort()
index_files.sort()
data = [os.path.join(path, e) for e in data_files]
......
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from nvidia.dali import ops
except ImportError:
ops = None
from dragon.core.util import six
from dragon.vm.dali.core import context
from dragon.vm.dali.core import types
class Resize(object):
"""Resize the image.
Examples:
```python
# Resize to a fixed area
resize1 = dali.ops.Resize(resize_x=300, resize_y=300)
# Resize along the shorter side
resize2 = dali.ops.Resize(resize_shorter=600, max_size=1000)
# Resize along the longer side
resize3 = dali.ops.Resize(resize_longer=512)
```
"""
def __new__(
cls,
resize_x=None,
resize_y=None,
resize_shorter=None,
resize_longer=None,
max_size=None,
interp_type='TRIANGULAR',
):
"""Create a ``Resize`` operator.
Parameters
----------
resize_x : int, optional
The output image width.
resize_y : int, optional
The output image height.
resize_shorter : int, optional
Resize along the shorter side and limited by ``max_size``.
resize_longer : int, optional
Resize along the longer side.
max_size : int, optional, default=0
The limited size for ``resize_shorter``.
interp_type : {'NN', 'LINEAR', 'TRIANGULAR', 'CUBIC', 'GAUSSIAN', 'LANCZOS3'}, optional
The interpolation method.
"""
if isinstance(interp_type, six.string_types):
interp_type = getattr(types, 'INTERP_' + interp_type.upper())
return ops.Resize(
resize_x=resize_x,
resize_y=resize_y,
resize_shorter=resize_shorter,
resize_longer=resize_longer,
max_size=max_size,
interp_type=interp_type,
device=context.get_device_type(),
)
......@@ -35,14 +35,7 @@ master_doc = 'index'
source_suffix = '.rst'
# Extension
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinxcontrib.katex',
'breathe',
]
napoleon_use_rtype = False
extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.katex', 'breathe']
# Project
project = 'dragon'
......
......@@ -22,7 +22,6 @@ NUMBER_OF_PROCESSORS:=$(shell getconf _NPROCESSORS_ONLN)
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " debughtml to make debugging HTML files"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
......@@ -30,11 +29,6 @@ clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)."
debughtml:
$(SPHINXBUILD) -b html -j ${NUMBER_OF_PROCESSORS} $(ALLSPHINXOPTS) $(BUILDDIR)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)."
......
......@@ -25,6 +25,9 @@ vm.caffe
: The Momentum-SGD solver.
`[Polyak, 1964] <https://doi.org/10.1016/0041-5553(64)90137-5>`_.
`class Solver <caffe/Solver.html>`_
: The base solver class to optimize parameters.
.. toctree::
:hidden:
......@@ -33,6 +36,7 @@ vm.caffe
caffe/Net
caffe/RMSPropSolver
caffe/SGDSolver
caffe/Solver
.. raw:: html
......
......@@ -12,30 +12,36 @@ Properties
base_lr
#######
.. autoattribute:: dragon.vm.caffe.AdamSolver.base_lr
.. autoattribute:: dragon.vm.caffe.Solver.base_lr
:noindex:
iter
####
.. autoattribute:: dragon.vm.caffe.AdamSolver.iter
.. autoattribute:: dragon.vm.caffe.Solver.iter
:noindex:
net
###
.. autoattribute:: dragon.vm.caffe.AdamSolver.net
.. autoattribute:: dragon.vm.caffe.Solver.net
:noindex:
test_nets
#########
.. autoattribute:: dragon.vm.caffe.AdamSolver.test_nets
.. autoattribute:: dragon.vm.caffe.Solver.test_nets
:noindex:
Methods
-------
snapshot
########
.. automethod:: dragon.vm.caffe.AdamSolver.snapshot
.. automethod:: dragon.vm.caffe.Solver.snapshot
:noindex:
step
########
.. automethod:: dragon.vm.caffe.AdamSolver.step
.. automethod:: dragon.vm.caffe.Solver.step
:noindex:
.. raw:: html
......
......@@ -12,30 +12,36 @@ Properties
base_lr
#######
.. autoattribute:: dragon.vm.caffe.NesterovSolver.base_lr
.. autoattribute:: dragon.vm.caffe.Solver.base_lr
:noindex:
iter
####
.. autoattribute:: dragon.vm.caffe.NesterovSolver.iter
.. autoattribute:: dragon.vm.caffe.Solver.iter
:noindex:
net
###
.. autoattribute:: dragon.vm.caffe.NesterovSolver.net
.. autoattribute:: dragon.vm.caffe.Solver.net
:noindex:
test_nets
#########
.. autoattribute:: dragon.vm.caffe.NesterovSolver.test_nets
.. autoattribute:: dragon.vm.caffe.Solver.test_nets
:noindex:
Methods
-------
snapshot
########
.. automethod:: dragon.vm.caffe.NesterovSolver.snapshot
.. automethod:: dragon.vm.caffe.Solver.snapshot
:noindex:
step
########
.. automethod:: dragon.vm.caffe.NesterovSolver.step
.. automethod:: dragon.vm.caffe.Solver.step
:noindex:
.. raw:: html
......
......@@ -12,30 +12,36 @@ Properties
base_lr
#######
.. autoattribute:: dragon.vm.caffe.RMSPropSolver.base_lr
.. autoattribute:: dragon.vm.caffe.Solver.base_lr
:noindex:
iter
####
.. autoattribute:: dragon.vm.caffe.RMSPropSolver.iter
.. autoattribute:: dragon.vm.caffe.Solver.iter
:noindex:
net
###
.. autoattribute:: dragon.vm.caffe.RMSPropSolver.net
.. autoattribute:: dragon.vm.caffe.Solver.net
:noindex:
test_nets
#########
.. autoattribute:: dragon.vm.caffe.RMSPropSolver.test_nets
.. autoattribute:: dragon.vm.caffe.Solver.test_nets
:noindex:
Methods
-------
snapshot
########
.. automethod:: dragon.vm.caffe.RMSPropSolver.snapshot
.. automethod:: dragon.vm.caffe.Solver.snapshot
:noindex:
step
########
.. automethod:: dragon.vm.caffe.RMSPropSolver.step
.. automethod:: dragon.vm.caffe.Solver.step
:noindex:
.. raw:: html
......
......@@ -12,30 +12,36 @@ Properties
base_lr
#######
.. autoattribute:: dragon.vm.caffe.SGDSolver.base_lr
.. autoattribute:: dragon.vm.caffe.Solver.base_lr
:noindex:
iter
####
.. autoattribute:: dragon.vm.caffe.SGDSolver.iter
.. autoattribute:: dragon.vm.caffe.Solver.iter
:noindex:
net
###
.. autoattribute:: dragon.vm.caffe.SGDSolver.net
.. autoattribute:: dragon.vm.caffe.Solver.net
:noindex:
test_nets
#########
.. autoattribute:: dragon.vm.caffe.SGDSolver.test_nets
.. autoattribute:: dragon.vm.caffe.Solver.test_nets
:noindex:
Methods
-------
snapshot
########
.. automethod:: dragon.vm.caffe.SGDSolver.snapshot
.. automethod:: dragon.vm.caffe.Solver.snapshot
:noindex:
step
########
.. automethod:: dragon.vm.caffe.SGDSolver.step
.. automethod:: dragon.vm.caffe.Solver.step
:noindex:
.. raw:: html
......
Solver
======
.. autoclass:: dragon.vm.caffe.Solver
__init__
--------
.. automethod:: dragon.vm.caffe.Solver.__init__
Properties
----------
base_lr
#######
.. autoattribute:: dragon.vm.caffe.Solver.base_lr
iter
####
.. autoattribute:: dragon.vm.caffe.Solver.iter
net
###
.. autoattribute:: dragon.vm.caffe.Solver.net
test_nets
#########
.. autoattribute:: dragon.vm.caffe.Solver.test_nets
Methods
-------
snapshot
########
.. automethod:: dragon.vm.caffe.Solver.snapshot
step
########
.. automethod:: dragon.vm.caffe.Solver.step
.. raw:: html
<style>
h1:before {
content: "caffe.";
color: #103d3e;
}
</style>
......@@ -33,9 +33,9 @@ source_suffix = '.rst'
# Extension
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinxcontrib.katex',
'sphinx_seeta_theme.ext.viewcode',
]
napoleon_use_rtype = False
......
......@@ -13,19 +13,22 @@ vm.dali.ops
: Transform bounding boxes to match the ``Paste`` operator.
`class BrightnessContrast <ops/BrightnessContrast.html>`_
: Adjust the brightness and contrast.
: Adjust the brightness and contrast of image.
`class Cast <ops/Cast.html>`_
: Cast the data type of input.
`class CoinFlip <ops/CoinFlip.html>`_
: Sample values from a bernoulli distribution.
`class CropMirrorNormalize <ops/CropMirrorNormalize.html>`_
: Crop and normalize input with the horizontal flip.
: Crop and normalize image with the horizontal flip.
`class ExternalSource <ops/Cast.html>`_
: Create a placeholder providing data from feeding.
`class Hsv <ops/Hsv.html>`_
: Adjust the hue and saturation.
: Adjust the hue and saturation of image.
`class ImageDecoder <ops/ImageDecoder.html>`_
: Decode image from bytes.
......@@ -40,7 +43,7 @@ vm.dali.ops
: Copy image into a larger canvas.
`class RandomBBoxCrop <ops/RandomBBoxCrop.html>`_
: Return a valid crop restricted by bounding boxes.
: Return an valid image crop restricted by bounding boxes.
`class Reshape <ops/Reshape.html>`_
: Change the dimensions of input.
......@@ -58,7 +61,7 @@ vm.dali.ops
: Read examples from the tf-record file.
`class Uniform <ops/Uniform.html>`_
: Select an interval of elements from input.
: Sample values from an uniform distribution.
.. toctree::
:hidden:
......
......@@ -175,8 +175,23 @@ __truediv__
.. _dragon.assign(...): assign.html
.. _dragon.cast(...): cast.html
.. _dragon.copy(...): copy.html
.. _dragon.fill(...): fill.html
.. _dragon.masked_assign(...): masked_assign.html
.. _dragon.masked_select(...): masked_select.html
.. _dragon.math.add(...): math/add.html
.. _dragon.math.div(...): math/div.html
.. _dragon.math.greater(...): math/greater.html
.. _dragon.math.greater_equal(...): math/greater_equal.html
.. _dragon.math.less(...): math/less.html
.. _dragon.math.less_equal(...): math/less_equal.html
.. _dragon.math.mul(...): math/mul.html
.. _dragon.math.negative(...): math/negative.html
.. _dragon.math.sub(...): math/sub.html
.. _dragon.random.glorot_normal(...): random/glorot_normal.html
.. _dragon.random.glorot_uniform(...): random/glorot_uniform.html
.. _dragon.random.normal(...): random/normal.html
.. _dragon.random.truncated_normal(...): random/truncated_normal.html
.. _dragon.random.uniform(...): random/uniform.html
.. _dragon.reshape(...): reshape.html
.. _dragon.slice(...): slice.html
......
......@@ -155,8 +155,23 @@ __truediv__
.. _dragon.assign(...): assign.html
.. _dragon.cast(...): cast.html
.. _dragon.copy(...): copy.html
.. _dragon.fill(...): fill.html
.. _dragon.masked_assign(...): masked_assign.html
.. _dragon.masked_select(...): masked_select.html
.. _dragon.math.add(...): math/add.html
.. _dragon.math.div(...): math/div.html
.. _dragon.math.greater(...): math/greater.html
.. _dragon.math.greater_equal(...): math/greater_equal.html
.. _dragon.math.less(...): math/less.html
.. _dragon.math.less_equal(...): math/less_equal.html
.. _dragon.math.mul(...): math/mul.html
.. _dragon.math.negative(...): math/negative.html
.. _dragon.math.sub(...): math/sub.html
.. _dragon.random.glorot_normal(...): random/glorot_normal.html
.. _dragon.random.glorot_uniform(...): random/glorot_uniform.html
.. _dragon.random.normal(...): random/normal.html
.. _dragon.random.truncated_normal(...): random/truncated_normal.html
.. _dragon.random.uniform(...): random/uniform.html
.. _dragon.reshape(...): reshape.html
.. _dragon.slice(...): slice.html
......
......@@ -20,7 +20,6 @@ if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. debughtml to make debugging HTML files
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. latexpdf to make LaTeX files and run them through pdflatex
goto end
......@@ -56,14 +55,6 @@ if errorlevel 9009 (
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%.
goto end
)
if "%1" == "debughtml" (
%SPHINXBUILD% -b html -j %NUMBER_OF_PROCESSORS% %ALLSPHINXOPTS% %BUILDDIR%
if errorlevel 1 exit /b 1
echo.
......
......@@ -12,7 +12,8 @@ Methods
__call__
########
.. automethod:: dragon.vm.tensorflow.keras.initializers.GlorotNormal.__call__
.. automethod:: dragon.vm.tensorflow.keras.initializers.VarianceScaling.__call__
:noindex:
.. raw:: html
......
......@@ -12,7 +12,8 @@ Methods
__call__
########
.. automethod:: dragon.vm.tensorflow.keras.initializers.GlorotUniform.__call__
.. automethod:: dragon.vm.tensorflow.keras.initializers.VarianceScaling.__call__
:noindex:
.. raw:: html
......
......@@ -479,6 +479,7 @@ zero\_
.. _torch.mul(...): mul.html
.. _torch.ne(...): ne.html
.. _torch.neg(...): neg.html
.. _torch.nonzero(...): nonzero.html
.. _torch.pow(...): pow.html
.. _torch.reciprocal(...): reciprocal.html
.. _torch.reshape(...): reshape.html
......@@ -487,8 +488,12 @@ zero\_
.. _torch.sign(...): sign.html
.. _torch.sin(...): sin.html
.. _torch.sqrt(...): sqrt.html
.. _torch.squeeze(...): squeeze.html
.. _torch.sub(...): sub.html
.. _torch.sum(...): sum.html
.. _torch.topk(...): topk.html
.. _torch.unsqueeze(...): unsqueeze.html
.. _torch.where(...): where.html
.. raw:: html
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Affine.__init__
.. _torch.nn.functional.affine(...): functional/affine.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.AvgPool2d.__init__
.. _torch.nn.functional.avg_pool2d(...): functional/avg_pool2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.BCEWithLogitsLoss.__init__
.. _torch.nn.functional.binary_cross_entropy_with_logits(...): functional/binary_cross_entropy_with_logits.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.BatchNorm1d.__init__
.. _torch.nn.functional.batch_norm(...): functional/batch_norm.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.BatchNorm2d.__init__
.. _torch.nn.functional.batch_norm(...): functional/batch_norm.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.BatchNorm3d.__init__
.. _torch.nn.functional.batch_norm(...): functional/batch_norm.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.CTCLoss.__init__
.. _torch.nn.functional.ctc_loss(...): functional/ctc_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ConstantPad1d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ConstantPad2d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ConstantPad3d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Conv2d.__init__
.. _torch.nn.functional.conv2d(...): functional/conv2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ConvTranspose2d.__init__
.. _torch.nn.functional.conv_transpose2d(...): functional/conv_transpose2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.CrossEntropyLoss.__init__
.. _torch.nn.functional.cross_entropy(...): functional/cross_entropy.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.DepthwiseConv2d.__init__
.. _torch.nn.functional.depthwise_conv2d(...): functional/depthwise_conv2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.DropBlock2d.__init__
.. _torch.nn.functional.drop_block2d(...): functional/drop_block2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.DropPath.__init__
.. _torch.nn.functional.drop_path(...): functional/drop_path.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Dropout.__init__
.. _torch.nn.functional.dropout(...): functional/dropout.html
.. raw:: html
<style>
......
......@@ -7,6 +7,7 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.GroupNorm.__init__
.. _torch.nn.functional.group_norm(...): functional/group_norm.html
.. raw:: html
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.L1Loss.__init__
.. _torch.nn.functional.l1_loss(...): functional/l1_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Linear.__init__
.. _torch.nn.functional.linear(...): functional/linear.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.LogSoftmax.__init__
.. _torch.nn.functional.log_softmax(...): functional/log_softmax.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.MSELoss.__init__
.. _torch.nn.functional.mse_loss(...): functional/mse_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.MaxPool2d.__init__
.. _torch.nn.functional.max_pool2d(...): functional/max_pool2d.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.NLLLoss.__init__
.. _torch.nn.functional.nll_loss(...): functional/nll_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.PReLU.__init__
.. _torch.nn.functional.prelu(...): functional/prelu.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReLU.__init__
.. _torch.nn.functional.relu(...): functional/relu.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReLU6.__init__
.. _torch.nn.functional.relu6(...): functional/relu6.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReflectionPad1d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReflectionPad2d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReflectionPad3d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReplicationPad1d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReplicationPad2d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ReplicationPad3d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.SELU.__init__
.. _torch.nn.functional.selu(...): functional/selu.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Sigmoid.__init__
.. _torch.nn.functional.sigmoid(...): functional/sigmoid.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.SigmoidFocalLoss.__init__
.. _torch.nn.functional.sigmoid_focal_loss(...): functional/sigmoid_focal_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.SmoothL1Loss.__init__
.. _torch.nn.functional.smooth_l1_loss(...): functional/smooth_l1_loss.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Softmax.__init__
.. _torch.nn.functional.softmax(...): functional/softmax.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.SyncBatchNorm.__init__
.. _torch.nn.functional.batch_norm(...): functional/batch_norm.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Tanh.__init__
.. _torch.nn.functional.tanh(...): functional/tanh.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.Upsample.__init__
.. _torch.nn.functional.interpolate(...): functional/interpolate.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.UpsamplingBilinear2d.__init__
.. _torch.nn.functional.interpolate(...): functional/interpolate.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.UpsamplingNearest2d.__init__
.. _torch.nn.functional.interpolate(...): functional/interpolate.html
.. raw:: html
<style>
......
......@@ -7,6 +7,8 @@ __init__
--------
.. automethod:: dragon.vm.torch.nn.ZeroPad2d.__init__
.. _torch.nn.functional.pad(...): functional/pad.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ affine
.. autofunction:: dragon.vm.torch.nn.functional.affine
.. _torch.nn.Affine(...): ../Affine.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ avg_pool2d
.. autofunction:: dragon.vm.torch.nn.functional.avg_pool2d
.. _torch.nn.AvgPool2d(...): ../AvgPool2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ batch_norm
.. autofunction:: dragon.vm.torch.nn.functional.batch_norm
.. _torch.nn.BatchNorm2d(...): ../BatchNorm2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ binary_cross_entropy_with_logits
.. autofunction:: dragon.vm.torch.nn.functional.binary_cross_entropy_with_logits
.. _torch.nn.BCEWithLogitsLoss(...): ../BCEWithLogitsLoss.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ conv2d
.. autofunction:: dragon.vm.torch.nn.functional.conv2d
.. _torch.nn.Conv2d(...): ../Conv2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ conv_transpose2d
.. autofunction:: dragon.vm.torch.nn.functional.conv_transpose2d
.. _torch.nn.ConvTranspose2d(...): ../ConvTranspose2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ cross_entropy
.. autofunction:: dragon.vm.torch.nn.functional.cross_entropy
.. _torch.nn.CrossEntropyLoss(...): ../CrossEntropyLoss.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ ctc_loss
.. autofunction:: dragon.vm.torch.nn.functional.ctc_loss
.. _torch.nn.CTCLoss(...): ../CTCLoss.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ depthwise_conv2d
.. autofunction:: dragon.vm.torch.nn.functional.depthwise_conv2d
.. _torch.nn.DepthwiseConv2d(...): ../DepthwiseConv2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ drop_block2d
.. autofunction:: dragon.vm.torch.nn.functional.drop_block2d
.. _torch.nn.DropBlock2d(...): ../DropBlock2d.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ drop_path
.. autofunction:: dragon.vm.torch.nn.functional.drop_path
.. _torch.nn.DropPath(...): ../DropPath.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ dropout
.. autofunction:: dragon.vm.torch.nn.functional.dropout
.. _torch.nn.Dropout(...): ../Dropout.html
.. raw:: html
<style>
......
......@@ -3,7 +3,7 @@ elu
.. autofunction:: dragon.vm.torch.nn.functional.elu
.. _torch.nn.ELU: ../ELU.html
.. _torch.nn.ELU(...): ../ELU.html
.. raw:: html
......
......@@ -3,6 +3,8 @@ group_norm
.. autofunction:: dragon.vm.torch.nn.functional.group_norm
.. _torch.nn.GroupNorm(...): ../GroupNorm.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ interpolate
.. autofunction:: dragon.vm.torch.nn.functional.interpolate
.. _torch.nn.Upsample(...): ../Upsample.html
.. raw:: html
<style>
......
......@@ -3,6 +3,8 @@ l1_loss
.. autofunction:: dragon.vm.torch.nn.functional.l1_loss
.. _torch.nn.L1Loss(...): ../L1Loss.html
.. raw:: html
<style>
......
......@@ -3,7 +3,7 @@ leaky_relu
.. autofunction:: dragon.vm.torch.nn.functional.leaky_relu
.. _torch.nn.LeakyReLU: ../LeakyReLU.html
.. _torch.nn.LeakyReLU(...): ../LeakyReLU.html
.. raw:: html
......
......@@ -3,6 +3,8 @@ linear
.. autofunction:: dragon.vm.torch.nn.functional.linear
.. _torch.nn.Linear(...): ../Linear.html
.. raw:: html
<style>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!