numpy array和python list_Python list与NumPy array 区分详解
1. 数据类型 type()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Yongqiang Cheng
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
current_directory = os.path.dirname(os.path.abspath(__file__))
import numpy as np
# import tensorflow as tf
import cv2
import time
print(16 * "++--")
print("current_directory:", current_directory)
PIXEL_MEAN = [123.68, 116.779, 103.939] # R, G, B. In TensorFlow, channel is RGB. In OpenCV, channel is BGR.
print("Python list")
print("PIXEL_MEAN:", PIXEL_MEAN)
print("type(PIXEL_MEAN):", type(PIXEL_MEAN))
print("type(PIXEL_MEAN[0]):", type(PIXEL_MEAN[0]), "\n")
PIXEL_MEAN_array = np.array(PIXEL_MEAN)
print("NumPy array")
print("PIXEL_MEAN_array:", PIXEL_MEAN_array)
print("type(PIXEL_MEAN_array):", type(PIXEL_MEAN_array))
print("type(PIXEL_MEAN_array[0]):", type(PIXEL_MEAN_array[0]))
print("PIXEL_MEAN_array.dtype:", PIXEL_MEAN_array.dtype)
/usr/bin/python2.7 /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow/yongqiang.py --gpu=0
++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--
current_directory: /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow
Python list
PIXEL_MEAN: [123.68, 116.779, 103.939]
type(PIXEL_MEAN):
type(PIXEL_MEAN[0]):
NumPy array
PIXEL_MEAN_array: [123.68 116.779 103.939]
type(PIXEL_MEAN_array):
type(PIXEL_MEAN_array[0]):
PIXEL_MEAN_array.dtype: float64
Process finished with exit code 0
2. 数据融合 (data fusion)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Yongqiang Cheng
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
current_directory = os.path.dirname(os.path.abspath(__file__))
import numpy as np
# import tensorflow as tf
import cv2
import time
print(16 * "++--")
print("current_directory:", current_directory)
PIXEL_MEAN = [123.68, 116.779, 103.939] # R, G, B. In TensorFlow, channel is RGB. In OpenCV, channel is BGR.
print("Python list")
print("PIXEL_MEAN:", PIXEL_MEAN)
print("type(PIXEL_MEAN):", type(PIXEL_MEAN))
print("type(PIXEL_MEAN[0]):", type(PIXEL_MEAN[0]), "\n")
PIXEL_MEAN_array = np.array(PIXEL_MEAN)
print("NumPy array")
print("PIXEL_MEAN_array:", PIXEL_MEAN_array)
print("type(PIXEL_MEAN_array):", type(PIXEL_MEAN_array))
print("type(PIXEL_MEAN_array[0]):", type(PIXEL_MEAN_array[0]))
print("PIXEL_MEAN_array.dtype:", PIXEL_MEAN_array.dtype, "\n")
image_array = np.array(
[[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], [[21, 22, 23], [24, 25, 26], [27, 28, 29], [30, 31, 32]]])
print("image_array:", image_array)
print("type(image_array):", type(image_array))
print("type(image_array[0]):", type(image_array[0]))
print("image_array.dtype:", image_array.dtype, "\n")
image_array_fusion = image_array + np.array(PIXEL_MEAN)
print("image_array_fusion:", image_array_fusion)
print("type(image_array_fusion):", type(image_array_fusion))
print("type(image_array_fusion[0]):", type(image_array_fusion[0]))
print("image_array_fusion.dtype:", image_array_fusion.dtype)
/usr/bin/python2.7 /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow/yongqiang.py --gpu=0
++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--
current_directory: /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow
Python list
PIXEL_MEAN: [123.68, 116.779, 103.939]
type(PIXEL_MEAN):
type(PIXEL_MEAN[0]):
NumPy array
PIXEL_MEAN_array: [123.68 116.779 103.939]
type(PIXEL_MEAN_array):
type(PIXEL_MEAN_array[0]):
PIXEL_MEAN_array.dtype: float64
image_array: [[[ 1 2 3]
[ 4 5 6]
[ 7 8 9]
[10 11 12]]
[[21 22 23]
[24 25 26]
[27 28 29]
[30 31 32]]]
type(image_array):
type(image_array[0]):
image_array.dtype: int64
image_array_fusion: [[[124.68 118.779 106.939]
[127.68 121.779 109.939]
[130.68 124.779 112.939]
[133.68 127.779 115.939]]
[[144.68 138.779 126.939]
[147.68 141.779 129.939]
[150.68 144.779 132.939]
[153.68 147.779 135.939]]]
type(image_array_fusion):
type(image_array_fusion[0]):
image_array_fusion.dtype: float64
Process finished with exit code 0
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持聚米学院。
numpy array和python list_Python list与NumPy array 区分详解相关推荐
- [Python从零到壹] 十一.数据分析之Numpy、Pandas、Matplotlib和Sklearn入门知识万字详解(1)
欢迎大家来到"Python从零到壹",在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界.所有文章都将结合案例.代码和作者的经验讲 ...
- python读二进制格点雷达基数据_对numpy中二进制格式的数据存储与读取方法详解...
使用save可以实现对numpy数据的磁盘存储,存储的方式是二进制.查看使用说明,说明专门提到了是未经压缩的二进制形式.存储后的数据可以进行加载或者读取,通过使用load方法. In [81]:np. ...
- python labelencoder参数_对python 数据处理中的LabelEncoder 和 OneHotEncoder详解
python 怎么读取 Label 里面的值 #简单来说 LabelEncoder 是对不连续的数字或者文本进行编号 from sklearn.preprocessing import LabelEn ...
- python截图黑屏_对Python获取屏幕截图的4种方法详解
Python获取电脑截图有多种方式,具体如下: PIL中的ImageGrab模块 windows API PyQt pyautogui PIL中的ImageGrab模块 import time imp ...
- python3 isinstance用法_对python中assert、isinstance的用法详解
1. assert 函数说明: Assert statements are a convenient way to insert debugging assertions into a program ...
- python实现连续变量最优分箱详解--CART算法
今天小编就为大家分享一篇python实现连续变量最优分箱详解–CART算法,具有很好的参考价值,希望对大家有所帮助.一起跟随小编过来看看吧 关于变量分箱主要分为两大类:有监督型和无监督型 对应的分箱方 ...
- 运用python的方式_对Python使用mfcc的两种方式详解
1.Librosa import librosa filepath = "/Users/birenjianmo/Desktop/learn/librosa/mp3/in.wav" ...
- Python+NetworkX画图的nx.draw_networkx(函数详解)
Python+NetworkX画图的nx.draw_networkx函数详解 Python+NetworkX画图的nx.draw_networkx(函数详解) Python+NetworkX画图的nx ...
- 【python教程入门学习】Python函数定义及传参方式详解(4种)
这篇文章主要介绍了Python函数定义及传参方式详解(4种),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 一.函数初识 1.定 ...
- python argv 详解_对python中的argv和argc使用详解
主要问题 为什么argv中第一个,即index=0的内容就是文件名? python中argc是用什么实现的? 概念解释 argc:argument counter,命令行参数个数 argv:argum ...
最新文章
- Unity3D游戏-愤怒的小鸟游戏源码和教程(二)
- vi和vim的基础使用
- 嵩天-Python语言程序设计程序题--第七周:文件和数据格式化
- oracle打patch,Oracle初学者入门指南-How to get Oracle Patch?
- linux 软raid配置-系统安装
- java 军工_为什么军工行业不用java而是选择继续用c(对于业务系统Java是非常合适的而不带操作系统的板子甚至可以做到微秒级别的实时控制)...
- Leetcode之整数反转
- 关于Mysql group_concat的应用(把相同ID的VAL用字符'/'连接起来)
- 从文本中提取单词生成单词本
- Python的Profile概述
- 顶部标题栏的布局设计
- 芯片在计算机中作用是什么,芯片的主要作用
- ESP8266 Arduino OLED
- 如何设置potplayer播放器把人声凸显出来并降噪?
- 激光测距望远镜方案介绍
- 搭建企业内外网可快速稳定访问的共享文件服务器方案
- YESCIO:谷歌SEO优化排名的8个核心因素
- Unity前项渲染和延迟渲染(二)
- (4.6.26)Android特殊系统的校验方式
- C语言二进制求数集子集
热门文章
- android中页面跳转以及数据在Activity之间的传递
- 如何通过nrpe设置Windows 内存检测
- delphi之鼠标模拟
- redis底层数据结构
- liunx 系统下面安装jdk
- PowerDesigner(八)-面向对象模型(用例图,序列图,类图,生成Java源代码及Java源代码生成类图)(转)...
- ASIHTTPRequest
- linux下挂载ntfs分区错误解决方法
- Ubuntu和Windows双系统调整启动顺序软件
- 合肥磨店职教城论坛使用WNMP平台架设 http://301302.net/