当前位置: 首页>>代码示例>>Python>>正文


Python ndarray.concatenate方法代码示例

本文整理汇总了Python中mxnet.ndarray.concatenate方法的典型用法代码示例。如果您正苦于以下问题:Python ndarray.concatenate方法的具体用法?Python ndarray.concatenate怎么用?Python ndarray.concatenate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mxnet.ndarray的用法示例。


在下文中一共展示了ndarray.concatenate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_anchors

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def generate_anchors(base_size=16, ratios=nd.array([0.5, 1, 2]), scales=2**nd.arange(3,6)):
    """
    Generate anchor (reference) windows by enumerating aspect ratios X
    scales wrt a reference (0, 0, 15, 15) window.
    This implementation matches the original Faster-RCNN RPN generate_anchors().
    But all calculations are on mxnet.ndarray.NDArray.

    Refer to 
    https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/rpn/generate_anchors.py
    """

    base_anchor = nd.array([1, 1, base_size, base_size])
    ratio_anchors = _ratio_enum(base_anchor, ratios)
    anchors = nd.concatenate([_scale_enum(ratio_anchors[i, :], scales)
                                 for i in range(ratio_anchors.shape[0])])
    return anchors 
开发者ID:linmx0130,项目名称:ya_mxdet,代码行数:18,代码来源:anchor_generator.py

示例2: ssd_generate_anchors

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def ssd_generate_anchors(scale, ratios=nd.array([0.5, 1, 2]), append_scale=None):
    """
    Generate anchor (reference) windows by enumerating aspect ratios X
    scales wrt a reference (0, 0, scale, scale) window.
    
    append_scale is used to generate an extra anchor whose scale is 
    sqrt{scale*append_scale}. Set append_scale=None to disenable this 
    extra anchor.
    """
    base_anchor = nd.array([1, 1, scale, scale])
    anchors = _ratio_enum(base_anchor, ratios)
    if append_scale is not None:
        ns = int(scale * append_scale)
        append_anchor = nd.round(nd.sqrt(nd.array([[1, 1, ns, ns]])))
        anchors = nd.concatenate([anchors, append_anchor], axis=0)
    return anchors 
开发者ID:linmx0130,项目名称:ya_mxdet,代码行数:18,代码来源:anchor_generator.py

示例3: _merge_multi_context

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def _merge_multi_context(outputs, major_axis):
    """Merge outputs that lives on multiple context into one, so that they look
    like living on one context.
    """
    rets = []
    for tensors, axis in zip(outputs, major_axis):
        if axis >= 0:
            rets.append(nd.concatenate(tensors, axis=axis, always_copy=False))
        else:
            # negative axis means the there is no batch_size axis, and all the
            # results should be the same on each device. We simply take the
            # first one, without checking they are actually the same
            rets.append(tensors[0])
    return rets 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:16,代码来源:DataParallelExecutorGroup.py

示例4: plot_loss

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def plot_loss(losses_log,global_step,epoch, i):
    message = '(epoch: %d, iters: %d) ' % (epoch, i)
    for key,value in losses_log.losses.items():
        if 'err' in key:
            loss = nd.concatenate(value,axis=0).mean().asscalar()
            sw.add_scalar('err', {key : loss}, global_step)
            message += '%s: %.6f ' % (key, loss)
    print(message) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:10,代码来源:train_srgan.py

示例5: plot_img

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def plot_img(losses_log):
    sw.add_image(tag='lr_img', image=nd.clip(nd.concatenate(losses_log['lr_img'])[0:4], 0, 1))
    sw.add_image(tag='hr_img', image=nd.clip(nd.concatenate(losses_log['hr_img'])[0:4], 0, 1))
    sw.add_image(tag='hr_img_fake', image=nd.clip(nd.concatenate(losses_log['hr_img_fake'])[0:4], 0, 1)) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:6,代码来源:train_srgan.py

示例6: plot_loss

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def plot_loss(losses_log,global_step,epoch, i):
    message = '(epoch: %d, iters: %d) ' % (epoch, i)
    for key,value in losses_log.losses.items():
        if 'loss_' in key:
            loss = nd.concatenate(value,axis=0).mean().asscalar()
            sw.add_scalar('loss', {key : loss}, global_step)
            message += '%s: %.3f ' % (key, loss)
    print(message) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:10,代码来源:train_cgan.py

示例7: plot_img

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def plot_img(losses_log):
    sw.add_image(tag='A', image=nd.clip(nd.concatenate([losses_log['real_A'][0][0:1],
                                                        losses_log['fake_B'][0][0:1],
                                                        losses_log['rec_A'][0][0:1],
                                                        losses_log['idt_A'][0][0:1]]) * 0.5 + 0.5, 0, 1))
    sw.add_image(tag='B', image=nd.clip(nd.concatenate([losses_log['real_B'][0][0:1],
                                                        losses_log['fake_A'][0][0:1],
                                                        losses_log['rec_B'][0][0:1],
                                                        losses_log['idt_B'][0][0:1]]) * 0.5 + 0.5, 0, 1)) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:11,代码来源:train_cgan.py

示例8: _mkanchors

# 需要导入模块: from mxnet import ndarray [as 别名]
# 或者: from mxnet.ndarray import concatenate [as 别名]
def _mkanchors(ws, hs, x_ctr, y_ctr):
    """
    Given a vector of widths (ws) and heights (hs) around a center
    (x_ctr, y_ctr), output a set of anchors (windows).
    """

    ws = ws.reshape((-1, 1))
    hs = hs.reshape((-1, 1))
    anchors = nd.concatenate(
                        [x_ctr - 0.5 * (ws - 1),
                         y_ctr - 0.5 * (hs - 1),
                         x_ctr + 0.5 * (ws - 1),
                         y_ctr + 0.5 * (hs - 1)], axis=1)
    return anchors 
开发者ID:linmx0130,项目名称:ya_mxdet,代码行数:16,代码来源:anchor_generator.py


注:本文中的mxnet.ndarray.concatenate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。