方法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. 201904:Action recognition based on 2D skeletons extracted from RGB videos

    论文标题:Action recognition based on 2D skeletons extracted from RGB videos 发表时间:02 April 2019 解决问题/主要思想 ...

  2. Photoshop 基础一 安装

     安装 版本介绍 学习教程  一.安装 1)注册Adobe账号,注册地址:Adobe注册 2)下载地址:Adobe下载 下载地址2:百度经验 3)安装:试用期7天的版本 二.版本介绍 1)最新版本:A ...

  3. <转>七种测试驱动模式

    本文转载自微信公众号:中国软件测试联盟 在进行软件测试时,我们都需要一个出发点,从哪里开始分析?测试设计是基于什么?简单说,就是什么驱动测试工作的进行? 基于对软件工程.产品质量和测试的理解,归纳出以 ...

  4. 如何把js的代码写的更加容易维护(一)--面向对象编程

    总是头疼javascript的代码写起来不可维护,那么看看下面的代码: (function (w, $) { var app = { init: function () { var me = this ...

  5. 微信小程序 wx.getUserInfo 解密 C# 代码 - 转

    public static string DecodeUserInfo(string raw, string signature,string encryptedData, string iv) { ...

  6. C# 百度TTS,文本转语音,RestAPI之Get请求

    因为用得到,所以作个记录: 代码如下: public class BaiduTTSService : IBaiduTTSService { public string tok = GetBaiduTo ...

  7. bash:express:command not found

    重新设置了node_global和node_cache目录后,总是显示command not found 找了几篇博文后,终于解决了这个问题   步骤如下: 1.新建node_global和node_ ...

  8. 蓝牙 link timeout分析

    蓝牙主机和蓝牙设备建立连接之后,会在l2cap 层面上建立相应的channel,这些channel 基本上是用于各种不同的profile 或者protocol 进行通信用的. 当相应的profile或 ...

  9. Webpack 2 视频教程 002 - NodeJS 安装与配置

    原文发表于我的技术博客 这是我免费发布的高质量超清「Webpack 2 视频教程」. Webpack 作为目前前端开发必备的框架,Webpack 发布了 2.0 版本,此视频就是基于 2.0 的版本讲 ...

  10. 手机APP自动化之uiautomator2 +python3 UI自动化

    题记: 之前一直用APPium直到用安卓9.0  发现uiautomatorviewer不支持安卓 9.0,点击截屏按钮 一直报错,百度很久解决方法都不可以,偶然间看见有人推荐:uiautomator ...