![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深度学习
xinfeng2005
这个作者很懒,什么都没留下…
展开
-
PIL Image resize methods
NEAREST从输入图像中选择一个最近的像素。忽略所有其他输入像素。BILINEAR (推荐)若要调整大小,请对所有可能影响输出值的像素使用线性插值计算输出像素值。对于其他变换,使用输入图像中2x2环境上的线性插值。BICUBIC若要调整大小,请对所有可能影响输出值的像素使用三次插值计算输出像素值。对于其他变换,在输入图像中使用4x4环境上的三次插值。...原创 2021-07-16 09:43:32 · 215 阅读 · 0 评论 -
shapely 多边形缩放
from shapely.geometry import Polygon, Point, LinearRingimport cv2import numpy as npxx = [(10, 10), (12,100), (100, 100), (20,20), (20,10)]poly = Polygon(xx)a = poly.buffer(-31)print(len(list(a.exterior.coords)))img = np.zeros((200,200,3), dtype=np..原创 2020-09-02 10:18:33 · 1339 阅读 · 0 评论 -
keras模型可视化,层可视化及kernel可视化
keras模型可视化:model:model = Sequential()# input: 100x100 images with 3 channels -> (100, 100, 3) tensors.# this applies 32 convolution filters of size 3x3 each.model.add(ZeroPadding2D((1,1), inp原创 2017-12-02 18:39:38 · 13123 阅读 · 10 评论 -
keras实现aspect level中文文本情感分类-源自EMNLP2016
原论文:http://link.zhihu.com/?target=https%3A//arxiv.org/pdf/1605.08900v2.pdf代码实现:#coding=utf-8import csv,codecsimport jieba# jieba.load_userdict('wordDict.txt')import pandas as pdfrom keras.pr原创 2018-01-02 08:36:09 · 2035 阅读 · 10 评论 -
python实现viterbi算法
states = ('Healthy', 'Fever')observations = ('normal', 'cold', 'dizzy')start_probability = {'Healthy': 0.6, 'Fever': 0.4}transition_probability = { 'Healthy': {'Healthy': 0.7, 'Fever': 0.3},原创 2018-01-10 15:17:22 · 1003 阅读 · 0 评论 -
use sklean.model_select.GridSearchCV to find keras best parameters
#coding=utf-8import numpy as npimport kerasfrom keras.wrappers.scikit_learn import KerasClassifierfrom keras.activations import *from keras.models import *from keras.layers import *from keras.原创 2018-02-04 15:53:38 · 394 阅读 · 0 评论 -
VGG 识别结果关注区域分析代码
#coding=utf-8#keras=2.0.2#tensorflow=1.1.0from keras.applications.vgg16 import VGG16, preprocess_input, decode_predictionsfrom keras.preprocessing import imageimport keras.backend as Kimport nu原创 2018-03-16 09:05:21 · 636 阅读 · 0 评论 -
keras attention code
#lstm+attentioninputs = Input(shape=(TIME_STEPS, INPUT_DIM,))lstm_units = 32lstm_out = LSTM(lstm_units, return_sequences=True)(inputs)a = Permute((2, 1))(lstm_out)a = Reshape((input_dim, TIME_ST...原创 2018-04-17 09:33:09 · 1313 阅读 · 1 评论 -
python基于dlib的人脸定位与人脸比对实现
import dlibcurrent_path = os.getcwd() # 获取当前路径# 模型路径predictor_path = current_path + "\\model\\shape_predictor_68_face_landmarks.dat"face_rec_model_path = current_path + "\\model\\dlib_face_recognitio...原创 2018-05-05 09:39:35 · 5485 阅读 · 0 评论 -
keras循环多输入模型的处理
def create_model(): def sum_add(x): x = K.sum(x, axis=1, keepdims=False) return x #############model1######################################################### input_1 = Inp...原创 2018-05-24 08:46:42 · 1940 阅读 · 0 评论 -
keras GPU 配置灵活使用
1、指定GPUimport osos.environ["CUDA_VISIBLE_DEVICES"] = "2"2、按需分配import tensorflow as tfimport keras.backend.tensorflow_backend as KTFconfig = tf.ConfigProto() config.gpu_options.allow_growth=True #不全...原创 2018-06-08 08:44:05 · 2162 阅读 · 1 评论 -
pytorch model flops and parameters count
1. flops caculate:import redef get_num_gen(gen): return sum(1 for x in gen)def flops_layer(layer): """ Calculate the number of flops for given a string information of laye...原创 2019-03-06 16:29:00 · 813 阅读 · 0 评论 -
keras实现Unet进行字符定位与识别分类
#coding=utf-8import cv2import numpy as npfrom keras.utils import to_categoricalfrom model.augmentations import randomHueSaturationValue, randomShiftScaleRotate, randomHorizontalFlipfrom keras.ca原创 2017-11-09 09:46:34 · 2959 阅读 · 1 评论 -
keras实现BiLSTM+CNN+CRF文字标记NER
import kerasfrom sklearn.model_selection import train_test_splitimport tensorflow as tffrom keras.callbacks import ModelCheckpoint,Callback# import keras.backend as Kfrom keras.layers import *fr原创 2017-11-09 09:41:17 · 15482 阅读 · 7 评论 -
利用keras框架cnn+ctc_loss识别不定长字符图片
# -*- coding: utf-8 -*-#keras==2.0.5#tensorflow==1.1.0import os,sys,stringimport sysimport loggingimport multiprocessingimport timeimport jsonimport cv2import numpy as npfrom sklearn.model原创 2017-10-18 22:35:20 · 15912 阅读 · 23 评论 -
numpy实现RNN训练机器做加减法,完整注释
本文来源自:https://iamtrask.github.io/2015/11/15/anyone-can-code-lstm/http://blog.csdn.net/vbskj/article/details/52107538# coding=utf-8import copy, numpy as npnp.random.seed(0)# compute sigmo转载 2016-11-30 17:00:34 · 2056 阅读 · 0 评论 -
gensim word2vec
fromgensim.models import Word2Vecsys.argv.append('train_200000_split.utf8')sys.argv.append('ner_training_word2vec_200001.model')sys.argv.append('ner_training_word2vec_200001.vector')原创 2017-04-09 14:35:44 · 1231 阅读 · 0 评论 -
keras在构建LSTM模型时对变长序列的处理
print(np.shape(X))#(1920, 45, 20)X=sequence.pad_sequences(X, maxlen=100, padding='post')print(np.shape(X))#(1920, 100, 20)model = Sequential()model.add(Masking(mask_value=0,input_shape=(1原创 2017-03-31 16:40:25 · 14692 阅读 · 0 评论 -
TensorFlow 实现MLP
#coding=utf-8import numpy as npfrom numpy.random import RandomStateimport tensorflow as tfw1=tf.Variable(tf.random_normal([2,3],stddev=1,seed=1))b1=tf.Variable(tf.constant(0.1, shape=[2]))w2=t原创 2017-03-16 09:33:14 · 1809 阅读 · 0 评论 -
使用keras预训练VGG16模型参数分类图像并提取特征
#coding=utf-8#keras==0.3.0 theano==0.8.0 python==2.7.13from keras.models import Sequentialfrom keras.layers.core import Flatten, Dense, Dropoutfrom keras.layers.convolutional import Convolution2D,原创 2017-04-16 16:51:38 · 19223 阅读 · 9 评论 -
Keras 训练时不用将数据全部加入内存
How can I use Keras with datasets that don't fit in memory?You can do batch training using model.train_on_batch(X, y) and model.test_on_batch(X, y). See the models documentation.Alternativ原创 2017-05-11 09:45:12 · 10695 阅读 · 0 评论 -
win7 远程配置ubuntu14 python keras tensorflow 深度学习
1.远程工具XShell5(远程命令行)+XFTP5(文件传输)2.命令行安装python3.5sudo add-apt-repository ppa:fkrull/deadsnakes sudo apt-get update sudo apt-get install python3.5原创 2017-05-10 16:41:22 · 392 阅读 · 0 评论 -
fld to xml and xml to fld
#coding=utf-8#将fld框文件生成xml'''VOC20122007_000027.jpgThe VOC2007 DatabasePASCAL VOC2007flickr48650030personUnspecified00174101349351'''i原创 2017-06-27 13:49:53 · 379 阅读 · 0 评论 -
caffe-windows cpu下编译python接口/matlab接口
1.下载caffe-windwos:https://github.com/BVLC/caffe/tree/windows2.修改scripts/build_win.cmd:64行以后::: Change the settings here to match your setup :: Change MSVC_VERSION to 12 to use VS 2013 if原创 2017-07-20 09:51:17 · 373 阅读 · 0 评论 -
CRNN add digits
# for reproducibilitynp.random.seed(2016)K.set_image_dim_ordering('tf')# define some run parametersbatch_size = 32nb_epochs = 100examplesPer = 60000maxToAdd = 8hidden_units = 200size = 28# c原创 2017-07-18 09:43:59 · 840 阅读 · 1 评论 -
py-faster-rcnn配置CPU下运行demo.py
1.git数据git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git2.下载model文件,bash ./data/scripts/fetch_faster_rcnn_models.sh下载并解压:py-faster-rcnn/data/faster_rcnn_models/VGG16_f原创 2017-08-25 16:32:44 · 2916 阅读 · 0 评论 -
mxnet多层感知器、卷积神经网络测试
# coding=utf-8import mxnet as mximport matplotlib.pyplot as pltimport numpy as npimport structimport pickledef ImageToFloat(img): return img.reshape(img.shape[0],1,28,28).astype(np.float32)原创 2016-11-28 17:32:33 · 1267 阅读 · 0 评论