python矩阵水平镜像
方法1:
label = label.T[::-1].transpose()
方法2:
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
.Notes
Equivalent to m[:,::-1]. Requires the array to be at least 2-D.
Examples
>>> A = np.diag([1.,2.,3.])
>>> A
array([[ 1., 0., 0.],
[ 0., 2., 0.],
[ 0., 0., 3.]])
>>> np.fliplr(A)
array([[ 0., 0., 1.],
[ 0., 2., 0.],
[ 3., 0., 0.]])
>>> A = np.random.randn(2,3,5)
>>> np.all(np.fliplr(A) == A[:,::-1,...])
True
python矩阵水平镜像的更多相关文章
- Python3 图片水平镜像实现
# -*- coding: utf-8 -*- """ Created on Sun Feb 4 12:15:38 2018 @author: markli " ...
- Win8Metro(C#)数字图像处理--2.19图像水平镜像
原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像 [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码] ...
- Python 矩阵(线性代数)
Python 矩阵(线性代数) 这里有一份新手友好的线性代数笔记,是和深度学习花书配套,还被Ian Goodfellow老师翻了牌. 笔记来自巴黎高等师范学院的博士生Hadrien Jean,是针对& ...
- Python pip 国内镜像大全及使用办法
Python pip 国内镜像大全及使用办法 一.国内镜像 清华 https://pypi.tuna.tsinghua.edu.cn/simple 豆瓣 pip install -i http://p ...
- 解决UnicodeEncodeError。python的docker镜像增加locale 中文支持
用pandas的pd.read_excel()打开中文名的xlsx,报错,本来以为是xlrd的问题后来发现,是open()函数就报错: “UnicodeEncodeError: 'ascii' cod ...
- Python 矩阵与矩阵以及矩阵与向量的乘法
import numpy as np numpy模块的array相乘时,有两种方式:一是矩阵形式,二是挨个相乘. 需要用矩阵形式相乘时,则要用np.dot()函数. #矩阵与矩阵相乘a = np.ar ...
- Python PyPI中国镜像
from:http://blog.makto.me/post/2012-11-01/pypi-mirror from:http://www.pypi-mirrors.org/ from:http:// ...
- python 矩阵
python的numpy库提供矩阵运算的功能,因此我们在需要矩阵运算的时候,需要导入numpy的包. 1.numpy的导入和使用 from numpy import *;#导入numpy的库函数 im ...
- python解决使用镜像源来安装包
一.问题在进行python包安装的时候出现一个问题就是无法进行安装,且出现了如下的错误 报错代码 Retrying (Retry(total=4, connect=None, read=None, r ...
随机推荐
- 使用Nginx来解决跨域的问题
使用Nginx来解决跨域的问题 nginx的版本:(查看nginx命令: /usr/local/nginx/sbin/nginx -v) nginx/1.4.3 问题是:前端项目域名是 a.xxxx. ...
- PAT A1146 Topological Order (25 分)——拓扑排序,入度
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topol ...
- 【C语言】结构体占用字节数及存储与空间分配
我们都知道在数据类型中,char类型占1个字节,short占2个字节,int占4个字节,long占8个字节等等. 在计算结构体大小时需要考虑其内存布局,结构体在内存中存放是按单元存放的,每个单元多大取 ...
- c语言学习5
break 和 continue之间的区别: 在1000人中,募捐100000元,当达到10万元后结束 break 跳出当前循环,即 是终止循环,continue结束本次循环,不终止循环 #in ...
- Luogu3676 小清新数据结构题 动态点分治
传送门 换根类型的统计问题动态点分治都是很好做的. 设所有点的点权和为$sum$ 首先,我们先不考虑求$\sum\limits_i s_i^2$,先考虑如何在换根的情况下求$\sum\limits_i ...
- (转)Linux SSH配置和禁止Root远程登陆设置
原文 一.修改vi /etc/ssh/sshd_config 文件 1.修改默认端口:默认Port为22,并且已经注释掉了:修改是把注释去掉,并修改成其它的端口. 2.禁止root用户远程登陆:修改P ...
- mysql 添加字段,未响应
ddl是要请求锁整个表的,肯定是这个表上有DML事务了,也就是有其它会话在删除.修改.插入这个表并且未提交
- visual studio Web发布至 IIS WebDeploy出错(未能创建SSL/TLS安全通道)Could not create SSL/TLS secure channel
问题发生的原因是VS 15.9尝试使用系统默认值进行TLS握手,但是要在VS内的某处设置为TLS1.2. 此问题的解决方法是在部署项目的IIS服务器上启用TLS 1.2.例如,请按照此文章中的说明操作
- 如何写好一篇高质量的IEEE/ACM Transaction级别的计算机科学论文?
转自<知乎>如何写好一篇高质量的IEEE/ACM Transaction级别的计算机科学论文? 问题: 作为一个博士生,一直为写论文头疼,读过很多高质量论文,觉得写的真好,但是轮到自己写总 ...
- 历时25天,我的博客(www.ityouknow.com)终于又活了过来
时间回到2016年的7月10号,那时候我刚刚开始正式在博客园写博客,博客园的交流氛围很好,但鉴于博客园古老的界面,同时计划创建一个自己独立的博客,毕竟自己的博客怎么折腾都行. 那时候正在研究 Spri ...