
深度学习
文章平均质量分 52
Alive Ιеι
这个作者很懒,什么都没留下…
展开
-
实现word2sequence
coding=utf-8“”"author:leifunction: 实现的是构建词典,实现方法把句子转换为数字序列并将其翻转“”"class Word2Sequence(object):UNK_TAG = “UNK”PAD_TAG = “PAD”UNK = 0PAD = 1def __init__(self): self.dict = { self.UNK_TAG: self.UNK, self.PAD_TAG: self.PAD }原创 2021-08-05 10:18:17 · 600 阅读 · 0 评论 -
pytorch实现手写数字识别
coding=utf-8“”"author:leifunction: 使用pytorch完成手写数字的识别“”"import numpy as npfrom torch.utils.data import DataLoaderfrom torchvision.datasets import MNISTfrom torchvision.transforms import Compose, ToTensor, Normalizeimport torch.nn as nnimport torc原创 2021-08-05 10:16:40 · 556 阅读 · 0 评论 -
pytorch自实现线性回归和反向传播并画图
coding=utf-8“”"author:leifunction:“”"import torchimport matplotlib.pyplot as pltlearning_rate = 0.011、准备数据y = 3x + 0.8x = torch.rand((500, 1))y_true = x*0.3 + 0.82、通过模型计算y_predictw = torch.rand((1, 1), requires_grad=True)b = torch.empty((1, 1原创 2021-08-05 10:15:41 · 310 阅读 · 0 评论 -
matplotlib多个坐标系显示图像
from pylab import mpl设置显示中文字体mpl.rcParams[“font.sans-serif”] = [“SimHei”]设置正常显示符号mpl.rcParams[“axes.unicode_minus”] = Falsex = range(60)y_beijing = [random.uniform(10, 15) for i in x]y_shanghai = [random.uniform(15, 25) for i in x]创建1行两列的画布fig, ax原创 2021-04-13 21:17:49 · 283 阅读 · 1 评论 -
matplotlib画图的简单使用
import randomfrom pylab import mpl设置显示中文字体mpl.rcParams[“font.sans-serif”] = [“SimHei”]设置正常显示符号mpl.rcParams[“axes.unicode_minus”] = False0.生成数据x = range(60)y_beijing = [random.uniform(10, 15) for i in x]y_shanghai = [random.uniform(15, 25) for i in原创 2021-04-13 21:16:46 · 166 阅读 · 0 评论 -
pytorch实现mnist数据集的训练和预测
coding=utf-8“”"author:leifunction:“”"import osimport torchfrom torch.optim import Adamfrom torch.nn import functional as Ffrom torch import nnfrom torch.utils.data import DataLoaderfrom torchvision.datasets import MNISTfrom torchvision.transfor原创 2021-03-19 19:30:07 · 671 阅读 · 0 评论 -
pytorch的数据加载
coding=utf-8“”"author:leifunction:“”"import torchfrom torch.utils.data import Dataset, DataLoaderimport mathdata_path = “./data/SMSSpamCollection”完成数据集类class MyDataset(Dataset):def init(self):self.lines = open(data_path, encoding=“utf8”).readli原创 2021-03-18 08:35:36 · 216 阅读 · 2 评论 -
pytorch实现线性回归
coding=utf-8“”"author:leifunction:“”"from torch.optim import SGDimport torchfrom torch import nn定义一个device对象 如果要转换为gpu上运行device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)准备数据x = torch.rand([500, 1]).to(device)y_true = 3 * x原创 2021-03-18 08:34:25 · 180 阅读 · 0 评论 -
卷积神经网络完成mnist数据集的训练和测试
coding=utf-8“”"author:leifunction:“”"import numpy as npimport tensorflow as tf下载并载入Mnist 手写数字库(55000 * 28 * 28)from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets(‘mnist_data’, one_hot=True)one_hot 独热码(enco原创 2021-03-18 08:31:22 · 1336 阅读 · 0 评论 -
手动搭建神经网络实现mnist数据集的训练
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data载入数据集mnist = input_data.read_data_sets(“mnist_data”, one_hot=True)每个批次的大小batch_size = 100计算一共多少个批次n_batch = mnist.train.num_examples // batch_size定义两个placeholder 一张图片原创 2021-03-18 08:30:14 · 429 阅读 · 0 评论 -
tensorflow完成mnist数据集训练和验证
coding=utf-8“”"author:leifunction:“”"import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("./mnist_data/", one_hot=True)trainimgs, trai原创 2021-03-18 08:28:17 · 305 阅读 · 0 评论 -
tensorflow实现自己搭建线性回归
import tensorflow as tf定义线性回归def linearregression():“”"实现线性回归:return:“”"# 准备数据集 x[100, 1] 0.8*x + 0.7 = [100, 1]with tf.variable_scope(“orginal_name”):x = tf.random_normal([100, 1], mean=0, stddev=1)y_true = tf.matmul(x, [[0.8]]) + [[0.7]]# 建立原创 2021-03-18 08:26:39 · 193 阅读 · 0 评论 -
keras+tensorflow实现迁移学习
coding=utf-8“”"author:leifunction:迁移学习“”"import tensorflow as tffrom tensorflow.python import kerasfrom tensorflow.python.keras.preprocessing.image import ImageDataGenerator, load_img, img_to_arrayfrom tensorflow.python.keras.applications.vgg16 imp原创 2021-03-18 08:24:19 · 394 阅读 · 1 评论 -
keras利用已有模型进行预测
from tensorflow.python.keras.applications.vgg16 import VGG16, preprocess_input, decode_predictionsfrom tensorflow.python.keras.preprocessing.image import load_img, img_to_arraydef predict():model = VGG16()print(model.summary())# 预测一张图类别# 加载图片 要求是vgg原创 2021-03-18 08:23:07 · 1027 阅读 · 0 评论 -
keras+tensorflow搭建神经网络实现服装分类
构建神经网络进行时装模型训练与预测class SinleNN(object):# 建立神经网络模型model = keras.Sequential([ # 将输入数据的形状进行修改为扁平化 keras.layers.Flatten(input_shape=[28, 28]), # 定义隐藏层,128个神经元的网络层 keras.layers.Dense(128, activation=tf.nn.relu), # 10个类别的分类问题,输出神经元的个数和输出类别原创 2021-03-18 08:21:51 · 310 阅读 · 0 评论 -
tensorflow+keras搭建神经网络实现cifar100的训练
coding=utf-8“”"author:leifunction:“”"from tensorflow.python.keras.datasets import cifar100from tensorflow.python import kerasimport tensorflow as tffrom tensorflow.python.keras.applications import VGG16class CNNCifar(object):# 定义模型model = keras.原创 2021-03-18 08:19:30 · 769 阅读 · 0 评论 -
使用googlenet进行垃圾分类预测
数据集下载:https://aistudio.baidu.com/aistudio/datasetDetail/16630主要训练模型:coding=utf-8“”"author:leifunction:使用googlenet进行图片分类“”"import tensorflow as tffrom tensorflow.contrib import slimimport nump...原创 2019-11-26 16:06:25 · 756 阅读 · 0 评论 -
sklearn进行信誉分析
-- coding: utf-8 --“”"@Time : 19-9-12 上午10:51@Author : lei@Site :@File : crx信誉分析.py@Software: PyCharm“”"import pandas as pdfrom sklearn.feature_extraction import DictVectorizerfrom sklearn.m...原创 2019-11-20 15:57:34 · 241 阅读 · 0 评论 -
神经网络进行股票预测
-- coding: utf-8 --“”"@Time : 19-10-1 上午7:32@Author : lei@Site :@File : 神经网络预测股票.py@Software: PyCharm“”"股票预测import pandas as pdimport numpy as npfrom sklearn.model_selection import train_te...原创 2019-11-20 15:55:33 · 2485 阅读 · 0 评论 -
skearn进行皮肤病预测
-- coding: utf-8 --“”"@Time : 19-9-19 下午2:50@Author : lei@Site :@File : dermatology皮肤病.py@Software: PyCharm“”"import pandas as pdimport numpy as npfrom sklearn.ensemble import RandomForestCl...原创 2019-11-20 15:54:41 · 439 阅读 · 0 评论 -
sklearn进行房价预测
-- coding: utf-8 --“”"@Time : 19-9-21 下午7:09@Author : lei@Site :@File : 房价预测.py@Software: PyCharm“”"房价预测from sklearn.linear_model import LinearRegressionfrom sklearn.model_selection import t...原创 2019-11-20 15:53:21 · 548 阅读 · 0 评论 -
sklearn进行情感分析
-- coding: utf-8 --“”"@Time : 19-9-26 下午2:39@Author : lei@Site :@File : 情感分析.py@Software: PyCharm“”"情感分析from sklearn.model_selection import train_test_splitfrom sklearn.feature_extraction.te...原创 2019-11-20 15:52:05 · 1572 阅读 · 2 评论 -
cnn进行验证码识别
-- coding: utf-8 --“”"@Time : 19-9-20 下午8:12@Author : lei@Site :@File : captcha_train.py@Software: PyCharm“”"import tensorflow as tfimport os定义一个初始化权重的函数def weight_variables(shape):weight ...原创 2019-11-20 15:50:22 · 369 阅读 · 0 评论 -
cnn进行手写数字识别
-- coding: utf-8 --“”"@Time : 19-10-8 下午4:12@Author : lei@Site :@File : CNN3_mnist.py@Software: PyCharm“”"CNN实现mnist识别import tensorflow as tffrom tensorflow.contrib.layers import fully_conne...原创 2019-11-20 15:48:44 · 389 阅读 · 0 评论 -
机器人自己产生成语
-- coding: utf-8 --“”"@Time : 19-10-17 下午4:06@Author : lei@Site :@File : Cheng.py@Software: PyCharm“”"ai自己写成语import tensorflow as tfimport collectionsimport numpy as np成语数量 47247字的个数 49...原创 2019-11-20 15:47:34 · 324 阅读 · 0 评论 -
松鼠分类任务
-- coding: utf-8 --“”"@Time : 19-10-19 下午7:39@Author : lei@Site :@File : squirrel_image.py@Software: PyCharm“”"松鼠识别 0 1from sklearn.linear_model import LogisticRegressionfrom sklearn.metric...原创 2019-11-20 15:45:57 · 320 阅读 · 0 评论 -
机器人写唐诗,模型训练
coding=utf-8“”"author:leifunction: 机器人写唐诗“”"import tensorflow as tfimport numpy as npimport collectionsimport re提取数据def extract_data(file_path):poems = []with open(file_path, “r”, encoding...原创 2019-11-20 15:44:25 · 825 阅读 · 2 评论