- 博客(49)
- 资源 (7)
- 收藏
- 关注
原创 组卷积(group convolution)的理解
分组是日常生活中一种常见现象,如基于年龄分为幼年、儿童、青少年、青年、中年和老年等。在机器学习中,聚类算法的本质思想也是分组,即把未知数据基于一些特性分成一个个组,便于人们理解。在深度学习用到组思想的一个地方就是组卷积。组卷积最早出现是在AleNet,当初主要采用并行训练方式来训练。后来研究学者基于卷积的基本计算方式广义线性方程(或多元多项式方程)发现,当卷积网络中卷积核个数增多时,会出现卷积...
2019-08-22 14:31:38
4921
原创 linux服务器安装anaconda,然后远程使用jupyter----windows环境
linux服务器安装anaconda:1.1 下载安装脚本:wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh1.2 运行安装向导:bash Anaconda3-5.2.0-Linux-x86_64.sh1.3 确认是否安装成功:conda --versionlinux服务器...
2019-08-11 15:54:58
1004
原创 Opencv, PIL.Image和TensorFlow对图像进行resize(缩放)基于Python
一、基于OpenCV的方法def Resize_Image_cv2(img_name, height, width, method): ''' :param img_name: the name of image :param height, width: the resized heigth, width ''' img = cv2.imread(i...
2019-08-08 11:58:45
2006
原创 TensorFlow网络框架模型的保存和加载
在训练深度学习模型时, 需要对将模型的参数保存,以便以后的需要。以前训练深度学习模型主要关注网络的设计,对模型的保存和加载不太注意。最近写使用TensorFlow写深度学习框架,觉得有必要详细了解一下。最简单的保存和恢复模型的方法是使用 tf.train.Saver 对象。构造器给graph的所有变量,或是定义在列表里的变量,添加 save 和 restore ops。saver对象提供了方法...
2019-08-06 14:00:15
328
原创 基于TensorFlow的图像大小调整
import tensorflow as tfdef TF_image_Resize(path_to_images, method = 0, height =224, width =224): """ using tensorflow to preprocess image data params: method 0: Bilinear interpolation ...
2019-07-25 15:21:24
934
原创 TensorFlow批读取图片
# coding:utf-8from __future__ import print_functionimport osimport tensorflow as tfdef TF_image_data(path_to_images): """ using tensorflow to read and store data """ if not t...
2019-07-25 14:42:33
215
原创 Human Activity Recognition using GRU based on label replication strategy
import tensorflow as tfimport numpy as npfrom sklearn.metrics import classification_report# Load "X" (the neural network's training and testing inputs)from Preprocess_data import read_data_set...
2019-05-31 15:06:48
301
原创 Python绘制箱形图
#coding: utf-8from __future__ import absolute_importfrom __future__ import divisionfrom __future__ import print_functionimport matplotlib.pyplot as pltimport numpy as npall_data = np.loadtxt(...
2019-05-27 08:52:02
702
原创 matplotlib绘制两个柱状图
import matplotlib.pyplot as pltimport numpy as npdata_2 = [93, 92, 93, 91, 92,93]data_3 = [57,56, 57,56,56.,54]labels = ['HL', 'ED', 'HD_2', 'HD_all', 'Voting','ME']fig,ax = plt.subplots(f...
2019-05-27 08:50:32
3587
原创 Softmax 实现源代码
import numpy as npfrom numpy.core._rational_tests import denominatordef softmax(x): #implementation one """ Compute the softmax in a numerically stable way.""" x = x- np.max(x) ...
2019-03-22 15:05:46
1511
原创 Python实现Complement Entropy Loss 参考 ICLR 2019论文 COMPLEMENT OBJECTIVE TRAINING
import numpy as npdef zero_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = np.arange(...
2019-03-22 09:06:07
972
原创 One-hot编码Python实现(二)
def dense_to_one_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = np.arange(num_labels) *...
2019-03-21 13:35:45
708
原创 使用Python按照索引查找元素
#Search elements in every row using indexX = np.random.randint(1,10, [5,6])print(X)Y = np.array([0,3,2,4,5])length = len(X)B = [] for i in range(length): Index = np.take(X[i],Y[i]...
2019-03-21 09:11:06
2968
原创 特征选择之计算特征重要性(二):树森林 (forests of trees)
import numpy as npimport matplotlib.pyplot as pltfrom sklearn.datasets import make_classificationfrom sklearn.ensemble import ExtraTreesClassifierfrom sklearn.ensemble import RandomForestClassif...
2019-01-03 09:07:40
930
原创 特征选择之计算特征重要性(一):树森林 (forests of trees)
import numpy as npimport matplotlib.pyplot as pltfrom sklearn.datasets import make_classificationfrom sklearn.ensemble import ExtraTreesClassifierdata_matrix = np.loadtxt(open("table_11.csv", ...
2019-01-02 20:57:40
2408
原创 离散特征的转化LabelEncoder和OneHotEncoder
from sklearn.preprocessing import LabelEncoderfrom sklearn.preprocessing import OneHotEncoderimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsimport warn...
2018-12-22 14:57:57
659
原创 TypeError: The value of a feed cannot be a tf.Tensor object.几种情况
1、变量相同for i in range(config.training_epochs): for start, end in zip(range(0, config.train_count, config.batch_size), range(config.batch_size, config.train_count...
2018-12-11 20:47:54
3508
原创 Python按列和按行读取数据
def data_transform(heading, value): """ 按列读取 """ data_length = len(value) ticker_length =len(heading)-1 value_list=[] ticker_list =[] date_list =[] for i in range(tick...
2018-11-18 17:49:42
11787
原创 开源项目收集
https://github.com/loliverhennigh/Convolutional-LSTM-in-Tensorflow https://github.com/xylcbd/blogs_code/blob/master/algorithm-python-knn/knn.py https://machinelearningmastery.com/visualize-machine-lea...
2018-11-18 17:40:50
257
原创 Python将dat文件批转为csv和txt文件
DAT并不是一种标准文件。许多软件都使用这个扩展名,但文件含义不同。而许多数据分析软件也用这个扩展名保存数据。所以这要看具体的软件情况来定。DAT文件,可以按照扩展名来看就是DATA的意思,即数据文件,这类文件并没有进行绝对化的定义。dat文件批处理转为txt文件#utf-8import osimport syspath_0 =r"C:\Users\dell\Desktop\PAMAP2_...
2018-06-07 14:39:39
14399
3
原创 先验算法(Apriori Algorithm)原理及python代码实现
先验算法(Apriori Algorithm)是关联规则学习的经典算法之一。先验算法的设计目的是为了处理包含交易信息内容的数据库(例如,顾客购买的商品清单,或者网页常访清单。)而其他的算法则是设计用来寻找无交易信息(如Winepi算法和Minepi算法)或无时间标记(如DNA测序)的数据之间的联系规则。关联分析的目的是从大规模数据集中寻找有趣关系的任务。这些关系可以有两种形式:频繁项集或者关联规则...
2018-05-31 09:34:03
9977
原创 Deep Learning using Linear Support Vector Machines的简单实现
Deep Learning using Linear Support Vector Machines这篇论文主要用SVM分类器替代了softmax分类器,并用合页损失替代了交叉熵损失,具体定义如下:代码:# Copyright 2017 Abien Fred Agarap# Licensed under the Apache License, Version 2.0 (the "License...
2018-05-24 11:26:18
3172
8
原创 tensorflow的tensorboard的使用在Windows下的改进版及自定义读取函数
from __future__ import absolute_importfrom __future__ import divisionfrom __future__ import print_functionimport osimport tensorflow as tfimport sysimport numpy as npimport collectionsfrom sk...
2018-05-24 11:09:16
429
原创 交叉验证代码实现
import numpyimport mathfrom sklearn import svmfrom sklearn.metrics import accuracy_scoreimport sysdef svm_classifier(train_x, train_y, valid_x, valid_y, test_x, test_y): clf = svm.LinearSVC() clf.fit(...
2018-05-24 10:57:28
4430
原创 Correlation 矩阵可视化
import matplotlib.pyplot as pltimport pandasimport numpy as npdata_set ='C:/Users/dell/Desktop/3tables.csv'names= ['0','1','2']data_matrix = np.loadtxt(open(data_set, "rb"), delimiter=",", skipro...
2018-05-07 17:16:06
2351
原创 深度学习训练技巧
1.优化器。机器学习训练的目的在于更新参数,优化目标函数,常见优化器有SGD,Adagrad,Adadelta,Adam,Adamax,Nadam。其中SGD和Adam优化器是最为常用的两种优化器,SGD根据每个batch的数据计算一次局部的估计,最小化代价函数。学习速率决定了每次步进的大小,因此我们需要选择一个合适的学习速率进行调优。学习速率太大会导致不收敛,速率太小收敛速度慢。因此SGD通常训
2018-01-18 15:00:29
1281
原创 Python几种读取mat格式数据的方法
matlab中使用的数据一般会以mat的格式存储,用python读取有以下几种方法1、使用scipy,具体实现如下:import scipy.io as scioimport pandas as pddata_path="train.mat"#Method 1data = scio.loadmat(data_path)data_train_label=data_train.get('label')
2018-01-18 14:59:20
46796
2
原创 One_hot编码批处理实现
特征更多的时候是分类特征,而不是连续的数值特征。 比如一个人的特征可以是``[“male”, “female”]``, ["from Europe", "from US", "from Asia"], ["uses Firefox", "uses Chrome", "uses Safari", "uses Internet Explorer"]。 这样的特征可以高效的编码成整数,例如 ["male
2018-01-17 11:01:29
669
原创 将txt文件批处理转换为csv文件
convert_txt_to_csv(txt_path, csv_path): """Convert the txt file to csv file""" #list to store the filenames and the path data = list_files(path=txt_path) csv_data=[] #l
2018-01-11 21:38:25
6114
原创 关联神经网络代码实现
最近看了一篇Correlational Neural Networks 的论文,这篇论文主利用到迁移学习思想以下是简单的实现代码def Autoencoder(left_input,right_input,left_units=None, right_units=None, hidden_units=None): #Initialization
2018-01-11 15:45:29
920
原创 边缘计算简介
边缘计算是指在网络边缘执行计算的一种新型计算模型,边缘计算中边缘的下行数据表示云服务,上行数据表示物联网服务,而边缘计算的边缘是指从数据源到云计算中心路径之间的任意计算资源和网络资源。比如,可穿戴的医疗设备可被视为个人用户与云计算中心之间的边缘,智能家居中网关可被视为家庭内电子设备和云计算中心之间的边缘、Cloudlet可被视为移动设备和云计算中心之间的边缘。边缘计算的基本原理是将计算任务迁移到产
2018-01-11 15:31:04
4555
原创 常见轻量级深度学习模型
深度学习模型参数很多(模型很大)是制约深度学习模型部署在移动端一个很大的瓶颈,最近有不少轻量级的深度学习模型提出,以下是对一些经典轻量级深度学习模型的总结:1、Squeezenet:Alexnet-level accuracy with 50x fewer parameters and¡ 1mb model size.arXiv preprint arXiv:1602.07360, 201
2018-01-11 15:16:28
6282
原创 Python中super()方法
在面向对象编程中,子类经常要调用父类的方法,在Python中,也不例外。为了调用父类(超类)的一个方法,可以使用 super() 函数,比如:class A: def spam(self): print('A.spam')class B(A): def spam(self): print('B.spam') super
2017-08-15 14:52:06
1145
转载 卷积神经网络残差计算
输出层的残差 和BP一样,CNN的输出层的残差与中间层的残差计算方式不同,输出层的残差是输出值与类标值得误差值,而中间各层的残差来源于下一层的残差的加权和。输出层的残差计算如下:下一层为采样层(subsampling)的卷积层的残差 当一个卷积层L的下一层(L+1)为采样层,并假设我们已经计算得到了采样层的残差,现在计算该卷积层的残差。从最上面的网络结构图我们知道,
2017-08-02 16:27:10
8501
原创 Python中lambda和in指用法小结
in的用法小结枚举或遍历>>> for i in range(100): print(i) 01234567判断if 1 in aa:print 'Very Good'else:print 'Not Bad'筛选if 'a' in 'dcv55a'print 'ok'字典中用法my_dict = {i: i * i
2017-07-28 11:28:53
2985
原创 csv文件转化为数组及数组的切片
在Python中我们经常会用到两个库Numpy和pandascsv文件转化为数组import numpymy_matrix = numpy.loadtxt(open("c:\\1.csv","rb"),delimiter=",",skiprows=0) //CSV文件转化为数组将数组或者矩阵存储为csv文件可以使用如下代码实现:numpy.savetxt('new.csv', my_ma
2017-07-27 20:36:56
6789
转载 numpy中矩阵有关函数
创建矩阵对于python中的numpy模块,一般用其提供的ndarray对象。 创建一个ndarray对象很简单,只要将一个list作为参数即可。 例如import numpy as np #引入numpy库#创建一维的narray对象a = np.array([1,2,3,4,5])#创建二维的narray对象a2 = np.array([[1,2,3,4,5],[6
2017-07-25 09:02:36
1281
原创 Python中numpy和pandas中axis浅谈
在Python中轴是比较难懂概念,先从坐标轴说起。n 维空间里有 n 个坐标轴,并且坐标轴互相垂直,每一个点相对于一条坐标轴都有唯一的一个坐标值。对同一条坐标轴来说,坐标值相同的点在同一个 n-1 维的“平面”上。任意取一个“平面”,我们就能定义“同一个坐标轴上的点”,这些点在“平面”上的投影相同,同一个坐标轴上的点组成的线是与坐标轴平行的。而所谓的延轴计算实际上是降维的过程,同一个坐标轴
2017-07-25 08:43:06
2805
转载 Python 读取csv的某行
假设CSV文件内容如下:No.,Name,Age,Score1,Apple,12,982,Ben,13,973,Celia,14,964,Dave,15,95保存为“A.csv“,利用Python自带的 csv模块 ,有两种方法可以实现提取其中的一行:方法一:reader第一种方法使用reader函数,接收一个可迭代的对象(比如csv文件),能返回一个生成器,
2017-07-12 20:28:27
2582
Deep Learning using Linear Support Vector Machines实现
2018-05-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人