python
龚慧林
积极、乐观、努力
展开
-
fuzzy cmeans
from __future__ import division, print_functionimport numpy as npfrom numpy.linalg import choleskyimport matplotlib.pyplot as pltimport skfuzzy as fuzzimport argparseimport sysimport random#...原创 2019-10-22 09:56:43 · 562 阅读 · 0 评论 -
mnist数据集保存为图片
#coding: utf-8from tensorflow.examples.tutorials.mnist import input_dataimport scipy.miscimport osimport numpy as np# 读取MNIST数据集。如果不存在会事先下载。mnist = input_data.read_data_sets("MNIST_data/", one...原创 2019-10-21 22:07:55 · 2927 阅读 · 0 评论 -
python文件读写1
# -*- coding: utf-8 -*-# read txt filedef readTextFile(file): f = open(file, 'r') # 尽可能多的读取文件的内容,一般会将整个文件内容都会读取 context = f.read() print(context) f.close() def readTextFileByLines(file...原创 2019-10-21 21:44:42 · 289 阅读 · 0 评论 -
基于mxnet的BP神经网络识别26个英文小写字母
import logginglogging.getLogger().setLevel(logging.INFO)import mxnet as mximport numpy as npfname = mx.test_utils.download('http://archive.ics.uci.edu/ml/machine-learning-databases/letter-recogn...原创 2019-10-06 13:47:12 · 737 阅读 · 2 评论 -
python解析json
“data.json”文件内容如下:{ "id":"1220562", "alt":"http:\/\/book.douban.com\/book\/1220562", "rating":{"max":10, "average":"7.0", "numRaters":282, "min":0}, "author":[{"name":"片山恭一"}, {...原创 2019-10-06 13:56:50 · 182 阅读 · 0 评论 -
python文件和目录
# -*- coding: utf-8 -*-import osdef printFile(rootDir): allFiles = os.listdir(rootDir) #列出文件夹下所有文件和目录 for i in range(0, len(allFiles)): # print(rootDir + allFiles[i]) path = os.path.join(ro...原创 2019-10-06 14:14:05 · 197 阅读 · 2 评论 -
tensorflow 1
import tensorflow as tfimport numpy as npimport matplotlib.pylab as pltdef tfDemo1(): #create data x_data = np.random.rand(100).astype(np.float32) y_data = x_data * 0.1 + 0.3 #create tensorf...原创 2019-10-06 14:16:24 · 173 阅读 · 0 评论 -
matplotlib画图
import matplotlib.pyplot as pltimport numpy as npdef test1(): # 从[-1,1]中等距去50个数作为x的取值 x = np.linspace(-1, 1, 50) print(x) y = 2*x + 1 y1 = 2**x + 1 # 第一个是横坐标的值,第二个是纵坐标的值 ...原创 2019-10-07 16:00:16 · 149 阅读 · 0 评论 -
tensorflow mnist 1
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_dataimport keras.backend.tensorflow_backend as KTFdef add_layer(inputs,in_size,out_size,activation_function=None): ...原创 2019-10-07 16:00:05 · 148 阅读 · 0 评论 -
tensorflow mnist 2
from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfimport keras.backend.tensorflow_backend as KTFmnist = input_data.read_data_sets("MNIST_data/", one_hot=True)x = ...原创 2019-10-07 15:59:55 · 131 阅读 · 0 评论 -
matplotlib画图 2
import numpy as npimport matplotlib.pyplot as plt# Compute the x and y coordinates for points on sine and cosine curvesx = np.arange(-3 * np.pi, 3 * np.pi, 0.1)y_sin = np.sin(x)y_cos = np.cos(x...原创 2019-10-07 15:59:46 · 127 阅读 · 0 评论 -
keras Regressor 回归
import numpy as npnp.random.seed(1337) # for reproducibilityfrom keras.models import Sequentialfrom keras.layers import Denseimport matplotlib.pyplot as plt # 可视化模块import tensorflow as tfimpo...转载 2019-10-07 16:15:25 · 418 阅读 · 0 评论 -
keras Classifier 分类
import numpy as npnp.random.seed(1337) # for reproducibilityfrom keras.models import Sequentialfrom keras.layers import Dense, Activationfrom keras.optimizers import RMSpropimport matplotlib.py...转载 2019-10-07 16:30:07 · 3640 阅读 · 0 评论 -
python线性回归 1
# -*- coding: utf-8 -*-import numpy as npfrom sklearn import linear_modelfrom sklearn.linear_model import LinearRegressionX = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])# y = 1 * x_0 + 2 * x_1 +...原创 2019-10-06 13:47:22 · 192 阅读 · 0 评论 -
python matplotlib画图 1
import numpy as npimport matplotlib.pyplot as plt# Compute the x and y coordinates for points on sine and cosine curvesx = np.arange(-3 * np.pi, 3 * np.pi, 0.1)y_sin = np.sin(x)y_cos = np.cos(x...原创 2019-10-06 13:47:31 · 152 阅读 · 0 评论 -
opencv python播放视频和保存视频
# -*- coding: utf-8 -*-import numpy as npimport cv2def playVideo(videoFile): cap = cv2.VideoCapture(videoFile) if cap.isOpened(): print("Open ", videoFile, " success!") else: print("Open ...原创 2019-09-30 12:15:59 · 2130 阅读 · 0 评论 -
python opencv画图
import numpy as npimport cv2def drawPic(): img=np.zeros((512,512,3), np.uint8) # Draw a diagonal blue line with thickness of 5 px cv2.line(img,(0,0),(511,511),(255,0,0),5) cv2.rectangle(img,...原创 2019-09-30 12:45:22 · 348 阅读 · 0 评论 -
python opencv调色板
# -*- coding: utf-8 -*-import numpy as npimport cv2def nothing(x): pass def palette(): img=np.zeros((300,1378,3),np.uint8) cv2.namedWindow('image') cv2.createTrackbar('R','image',0,255,not...原创 2019-09-30 12:48:59 · 552 阅读 · 0 评论 -
python opencv图像处理
# -*- coding: utf-8 -*-import numpy as npfrom matplotlib import pyplot as pltimport cv2def roiProcess(): file = "F:\\dataSet\\picture\\000006 (2).jpg" img=cv2.imread(file) # [startRow: end...原创 2019-09-30 12:54:59 · 338 阅读 · 0 评论 -
python opencv图像融合
# -*- coding: utf-8 -*-import numpy as npfrom matplotlib import pyplot as pltimport cv2def addWeight(): pic1 = 'F:\\dataSet\\picture\\000006 (2).jpg' pic2 = 'F:\\dataSet\\picture\\1.png' i...原创 2019-09-30 12:58:38 · 368 阅读 · 0 评论 -
python opencv图像滤波
# -*- coding: utf-8 -*-import numpy as npfrom matplotlib import pyplot as pltimport cv2def medianBlurTest(file): img1 = cv2.imread(file) #e1 = cv2.getTickCount() for i in range(1, 15, 2):...原创 2019-09-30 13:01:38 · 304 阅读 · 0 评论 -
python numpy 1
import numpy as npa = np.array([1, 2, 3]) # Create a rank 1 arrayprint(type(a)) # Prints "<class 'numpy.ndarray'>"print(a.shape) # Prints "(3,)"print(a[0], a[1], a[...原创 2019-09-30 13:23:02 · 170 阅读 · 0 评论 -
python numpy 2
import numpy as np# Create a new array from which we will select elementsa = np.array([[1,2,3], [4,5,6], [7,8,9], [10, 11, 12]])print(a) # prints "array([[ 1, 2, 3], # ...原创 2019-09-30 13:28:12 · 173 阅读 · 0 评论 -
python opencv载入图片
# -*- coding: utf-8 -*-"""Created on Sun Oct 14 19:58:58 2018@author: lin"""import numpy as npimport cv2# Load an color image in grayscaleimg = cv2.imread("G:\\picture\\flower.jpg", 0)# c...原创 2019-09-30 13:32:55 · 266 阅读 · 0 评论 -
python Fuzzy C-means
from __future__ import division, print_functionimport numpy as npfrom numpy.linalg import choleskyimport matplotlib.pyplot as pltimport skfuzzy as fuzzimport argparseimport sysimport random#...原创 2019-10-06 13:47:55 · 920 阅读 · 0 评论 -
Python OpenCV version
#!/usr/bin/env python'''prints OpenCV versionUsage: opencv_version.py [<params>] params: --build: print complete build info --help: print this help'''# Python 2...原创 2019-10-06 13:47:45 · 345 阅读 · 0 评论 -
python numpy 3
import numpy as npx = 3print(type(x)) # Prints "<class 'int'>"print(x) # Prints "3"print(x + 1) # Addition; prints "4"print(x - 1) # Subtraction; prints "2"print(x * 2) # Mul...原创 2019-10-06 13:47:39 · 141 阅读 · 0 评论 -
python读取图片并且显示
使用python-opencv读取图片,利用opencv或matplotlib显示图片。# -*- coding: utf-8 -*-import numpy as npfrom matplotlib import pyplot as plt#import urllibimport cv2def load_image1(file): # Load an color image...原创 2019-09-30 12:03:22 · 868 阅读 · 0 评论