方法1:

  1. label = label.T[::-1].transpose()

方法2:

  1. label = label[:,::-1]

方法3:

使用 numpy.fliplr

https://docs.scipy.org/doc/numpy/reference/generated/numpy.fliplr.html

numpy.fliplr

numpy.fliplr(m)[source]

Flip array in the left/right direction.

Flip the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before.

Parameters:

m : array_like

Input array, must be at least 2-D.

Returns:

f : ndarray

A view of m with the columns reversed. Since a view is returned, this operation is .

See also

flipud
Flip array in the up/down direction.
rot90
Rotate array counterclockwise.

Notes

Equivalent to m[:,::-1]. Requires the array to be at least 2-D.

Examples

  1. >>> A = np.diag([1.,2.,3.])
  2. >>> A
  3. array([[ 1., 0., 0.],
  4. [ 0., 2., 0.],
  5. [ 0., 0., 3.]])
  6. >>> np.fliplr(A)
  7. array([[ 0., 0., 1.],
  8. [ 0., 2., 0.],
  9. [ 3., 0., 0.]])
  10. >>> A = np.random.randn(2,3,5)
  11. >>> np.all(np.fliplr(A) == A[:,::-1,...])
  12. True

python矩阵水平镜像的更多相关文章

  1. Python3 图片水平镜像实现

    # -*- coding: utf-8 -*- """ Created on Sun Feb 4 12:15:38 2018 @author: markli " ...

  2. Win8Metro(C#)数字图像处理--2.19图像水平镜像

    原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像  [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码]      ...

  3. Python 矩阵(线性代数)

    Python 矩阵(线性代数) 这里有一份新手友好的线性代数笔记,是和深度学习花书配套,还被Ian Goodfellow老师翻了牌. 笔记来自巴黎高等师范学院的博士生Hadrien Jean,是针对& ...

  4. Python pip 国内镜像大全及使用办法

    Python pip 国内镜像大全及使用办法 一.国内镜像 清华 https://pypi.tuna.tsinghua.edu.cn/simple 豆瓣 pip install -i http://p ...

  5. 解决UnicodeEncodeError。python的docker镜像增加locale 中文支持

    用pandas的pd.read_excel()打开中文名的xlsx,报错,本来以为是xlrd的问题后来发现,是open()函数就报错: “UnicodeEncodeError: 'ascii' cod ...

  6. Python 矩阵与矩阵以及矩阵与向量的乘法

    import numpy as np numpy模块的array相乘时,有两种方式:一是矩阵形式,二是挨个相乘. 需要用矩阵形式相乘时,则要用np.dot()函数. #矩阵与矩阵相乘a = np.ar ...

  7. Python PyPI中国镜像

    from:http://blog.makto.me/post/2012-11-01/pypi-mirror from:http://www.pypi-mirrors.org/ from:http:// ...

  8. python 矩阵

    python的numpy库提供矩阵运算的功能,因此我们在需要矩阵运算的时候,需要导入numpy的包. 1.numpy的导入和使用 from numpy import *;#导入numpy的库函数 im ...

  9. python解决使用镜像源来安装包

    一.问题在进行python包安装的时候出现一个问题就是无法进行安装,且出现了如下的错误 报错代码 Retrying (Retry(total=4, connect=None, read=None, r ...

随机推荐

  1. Fedora安装Snapd和Snap软件包

    导读 Snappy包管理器是一个跨发行版的包管理器.它最初是为Ubuntu系统构建的,但现在其他主要的Linux发行版( Fedora, Linux Mint, RHEL, OpenSUSE,Arch ...

  2. vue 实现tab切换动态加载不同的组件

    vue 实现tab切换动态加载不同的组件 使用vue中的is特性来加载不同的组件.具体看如下代码:这个功能对于vue比较复杂的页面可以使用上,可以把一个页面的功能拆分出来,使代码更简单.使用方式具体看 ...

  3. esp-adf Element PipeLine

    audio_element: 开发基于ADF的程序软件最基本的模块就是audio_element对象.所有的编码.解码.过滤.输入流.输出流实际上都是audio_element.(这个是官方的文件我翻 ...

  4. Omi框架学习之旅 - 组件通讯(data通讯) 及原理说明

    接着上一篇的data-*通讯,这篇写data通讯. data通讯主要为了复杂的数据通讯. 老规矩:先上demo代码, 然后提出问题, 之后解答问题, 最后源码说明. class Hello exten ...

  5. Flask核心机制--上下文源码剖析

    一.前言 了解过flask的python开发者想必都知道flask中核心机制莫过于上下文管理,当然学习flask如果不了解其中的处理流程,可能在很多问题上不能得到解决,当然我在写本篇文章之前也看到了很 ...

  6. Zookeeper-基本概念

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务.它是一个典型的分布式数据一致性的解决方案,分布式应用可以基于它实现诸如数据发布/订阅.负载均衡.命名服务.分布式协调/通知.集群管理 ...

  7. [Spark][Python][DataFrame][SQL]Spark对DataFrame直接执行SQL处理的例子

    [Spark][Python][DataFrame][SQL]Spark对DataFrame直接执行SQL处理的例子 $cat people.json {"name":" ...

  8. 2.RapidIO串行物理层的包与控制符号

    转自https://www.cnblogs.com/liujinggang/p/9932150.html 一.RapidIO串行物理层背景介绍 上篇博文提到RapidIO的物理层支持串行物理层与并行物 ...

  9. 给echarts加个“全屏展示”

    echarts的工具箱并没有提供放大/全屏的功能, 查找文档发现可自定义工具https://www.echartsjs.com/option.html#toolbox.feature show代码 t ...

  10. grep精确匹配搜索某个单词的用法 (附: grep高效用法小结))

    grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正 ...