[556]python实现神经网络

2023-10-30

神经网络/人工神经网络的洋文是Neural Network,这个计算模型在上世纪40年代就出现了,但是直到2011、2012年由于大数据和深度学习的兴起,神经网络才得到广泛应用。

参看wiki神经网络:https://en.wikipedia.org/wiki/Artificial_neural_network

为了更好的理解Neural Network,本帖使用Python实现一个最简单的Feed-forward神经网络,然后使用MNIST数据集进行测试。

MNIST数据集简介

当我们学习新的编程语言时,通常第一个程序就是打印输出著名的“Hello World!”。在深度学习中,MNIST数据集就相当于Hello World。

MNIST是一个简单的计算机视觉数据集,它包含手写数字的图像集:

使用Python实现神经网络

MNIST数据集下载地址: Yann LeCun,网站貌似被墙。

数据集:

  • train-images-idx3-ubyte 训练数据图像 (60,000)
  • train-labels-idx1-ubyte 训练数据label
  • t10k-images-idx3-ubyte 测试数据图像 (10,000)
  • t10k-labels-idx1-ubyte 测试数据label

每张图像是28 * 28像素:

使用Python实现神经网络

我们的任务是使用上面数据训练一个可以准确识别手写数字的神经网络模型。

使用Python实现神经网络
import numpy as np
import random

class NeuralNet(object):

    # 初始化神经网络,sizes是神经网络的层数和每层神经元个数
    def __init__(self, sizes):
        self.sizes_ = sizes
        self.num_layers_ = len(sizes)  # 层数
        self.w_ = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])]  # w_、b_初始化为正态分布随机数
        self.b_ = [np.random.randn(y, 1) for y in sizes[1:]]

生成正态分布随机数

正态分布或高斯分布是常用的概率分布,参看wikipedia正态分布

生成正态分布随机数的方法很多,我选择使用Marsaglia and Bray方法。

使用Python numpy生成正态分布随机数:

>>> import numpy as np
>>> np.random.randn()   # 标准正态分布
>>> 2.5 * np.random.randn() + 3  # 等同于randn(3, 2.5)    np.random.normal(3,2.5)

image.png

上图网络的构造方法:

net = NeuralNet([3, 4, 2])
print('权重: ', net.w_)
print('biases: ', net.b_)
权重:  [array([[-0.03149996,  3.24885342,  0.89417842],
              [-0.53460464, -1.5079955 ,  1.82663781],
              [-1.65116615,  0.38629484, -0.41583065],
              [-0.01554273,  0.07004582,  0.21980528]]),
       array([[ 0.14899583,  0.51091601,  1.49353662, -0.14707524],
              [ 0.64196923,  1.37387519,  0.92405086,  0.68889039]])]
biases:  [array([[ 0.06612406],
                 [-0.5104788 ],
                 [ 0.62980541],
                 [-0.9225445 ]]),
          array([[-0.26442039],
                 [-0.91214809]])]

定义Sigmoid函数:

    # Sigmoid函数,S型曲线,
    def sigmoid(self, z):
        return 1.0/(1.0+np.exp(-z))
    # Sigmoid函数的导函数
    def sigmoid_prime(self, z):
        return self.sigmoid(z)*(1-self.sigmoid(z))

画出这个函数图像:

import numpy as np
from matplotlib import pyplot
 
def sigmoid(z):
    return 1.0/(1.0+np.exp(-z))
 
x  = np.linspace(-8.0,8.0, 2000)
y = sigmoid(x)
pyplot.plot(x,y)
pyplot.show()

image.png

上面使用Sigmoid函数做为神经网络中的激活函数,其作用就是引入非线性。它的优点在于输出范围有限(0, 1),所以数据在传递的过程中不容易发散。可选择的激活函数有很多。

定义feedforward函数:

    # 给神经网络的输入x,输出对应的值
    def feedforward(self, x):
        for b, w in zip(self.b_, self.w_):
            x = self.sigmoid(np.dot(w, x)+b)
        return x

定义随机梯度下降函数,赋予神经网络学习的能力:

    # training_data是训练数据(x, y); epochs是训练次数; mini_batch_size是每次训练样本数; eta是learning rate
    def SGD(self, training_data, epochs, mini_batch_size, eta, test_data=None):
        if test_data:
            n_test = len(test_data)
 
        n = len(training_data)
        for j in range(epochs):
            random.shuffle(training_data)
            mini_batches = [training_data[k:k+mini_batch_size] for k in range(0, n, mini_batch_size)]
            for mini_batch in mini_batches:
                self.update_mini_batch(mini_batch, eta)
            if test_data:
                print("Epoch {0}: {1} / {2}".format(j, self.evaluate(test_data), n_test))
            else:
                print("Epoch {0} complete".format(j)) 
   def backprop(self, x, y):
        nabla_b = [np.zeros(b.shape) for b in self.b_]
        nabla_w = [np.zeros(w.shape) for w in self.w_]
 
        activation = x
        activations = [x]
        zs = []
        for b, w in zip(self.b_, self.w_):
            z = np.dot(w, activation)+b
            zs.append(z)
            activation = self.sigmoid(z)
            activations.append(activation)
 
        delta = self.cost_derivative(activations[-1], y) * \
            self.sigmoid_prime(zs[-1])
        nabla_b[-1] = delta
        nabla_w[-1] = np.dot(delta, activations[-2].transpose())
 
        for l in range(2, self.num_layers_):
            z = zs[-l]
            sp = self.sigmoid_prime(z)
            delta = np.dot(self.w_[-l+1].transpose(), delta) * sp
            nabla_b[-l] = delta
            nabla_w[-l] = np.dot(delta, activations[-l-1].transpose())
        return (nabla_b, nabla_w)
 
    def update_mini_batch(self, mini_batch, eta):
        nabla_b = [np.zeros(b.shape) for b in self.b_]
        nabla_w = [np.zeros(w.shape) for w in self.w_]
        for x, y in mini_batch:
            delta_nabla_b, delta_nabla_w = self.backprop(x, y)
            nabla_b = [nb+dnb for nb, dnb in zip(nabla_b, delta_nabla_b)]
            nabla_w = [nw+dnw for nw, dnw in zip(nabla_w, delta_nabla_w)]
        self.w_ = [w-(eta/len(mini_batch))*nw for w, nw in zip(self.w_, nabla_w)]
        self.b_ = [b-(eta/len(mini_batch))*nb for b, nb in zip(self.b_, nabla_b)]
 
    def evaluate(self, test_data):
        test_results = [(np.argmax(self.feedforward(x)), y) for (x, y) in test_data]
        return sum(int(x == y) for (x, y) in test_results)
 
    def cost_derivative(self, output_activations, y):
        return (output_activations-y)

完整代码:

# -*- coding:utf-8 -*-
import numpy as np
import random
import os, struct
from array import array as pyarray
from numpy import append, array, int8, uint8, zeros


class NeuralNet(object):
    # 初始化神经网络,sizes是神经网络的层数和每层神经元个数
    def __init__(self, sizes):
        self.sizes_ = sizes
        self.num_layers_ = len(sizes)  # 层数
        self.w_ = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])]  # w_、b_初始化为正态分布随机数
        self.b_ = [np.random.randn(y, 1) for y in sizes[1:]]

    # Sigmoid函数,S型曲线,
    def sigmoid(self, z):
        return 1.0 / (1.0 + np.exp(-z))

    # Sigmoid函数的导函数
    def sigmoid_prime(self, z):
        return self.sigmoid(z) * (1 - self.sigmoid(z))

    def feedforward(self, x):
        for b, w in zip(self.b_, self.w_):
            x = self.sigmoid(np.dot(w, x) + b)
        return x

    def backprop(self, x, y):
        nabla_b = [np.zeros(b.shape) for b in self.b_]
        nabla_w = [np.zeros(w.shape) for w in self.w_]

        activation = x
        activations = [x]
        zs = []
        for b, w in zip(self.b_, self.w_):
            z = np.dot(w, activation) + b
            zs.append(z)
            activation = self.sigmoid(z)
            activations.append(activation)

        delta = self.cost_derivative(activations[-1], y) * \
                self.sigmoid_prime(zs[-1])
        nabla_b[-1] = delta
        nabla_w[-1] = np.dot(delta, activations[-2].transpose())

        for l in range(2, self.num_layers_):
            z = zs[-l]
            sp = self.sigmoid_prime(z)
            delta = np.dot(self.w_[-l + 1].transpose(), delta) * sp
            nabla_b[-l] = delta
            nabla_w[-l] = np.dot(delta, activations[-l - 1].transpose())
        return (nabla_b, nabla_w)

    def update_mini_batch(self, mini_batch, eta):
        nabla_b = [np.zeros(b.shape) for b in self.b_]
        nabla_w = [np.zeros(w.shape) for w in self.w_]
        for x, y in mini_batch:
            delta_nabla_b, delta_nabla_w = self.backprop(x, y)
            nabla_b = [nb + dnb for nb, dnb in zip(nabla_b, delta_nabla_b)]
            nabla_w = [nw + dnw for nw, dnw in zip(nabla_w, delta_nabla_w)]
        self.w_ = [w - (eta / len(mini_batch)) * nw for w, nw in zip(self.w_, nabla_w)]
        self.b_ = [b - (eta / len(mini_batch)) * nb for b, nb in zip(self.b_, nabla_b)]

    # training_data是训练数据(x, y);epochs是训练次数;mini_batch_size是每次训练样本数;eta是learning rate
    def SGD(self, training_data, epochs, mini_batch_size, eta, test_data=None):
        if test_data:
            n_test = len(test_data)

        n = len(training_data)
        for j in range(epochs):
            random.shuffle(training_data)
            mini_batches = [training_data[k:k + mini_batch_size] for k in range(0, n, mini_batch_size)]
            for mini_batch in mini_batches:
                self.update_mini_batch(mini_batch, eta)
            if test_data:
                print("Epoch {0}: {1} / {2}".format(j, self.evaluate(test_data), n_test))
            else:
                print("Epoch {0} complete".format(j))

    def evaluate(self, test_data):
        test_results = [(np.argmax(self.feedforward(x)), y) for (x, y) in test_data]
        return sum(int(x == y) for (x, y) in test_results)

    def cost_derivative(self, output_activations, y):
        return (output_activations - y)

    # 预测
    def predict(self, data):
        value = self.feedforward(data)
        return value.tolist().index(max(value))

    # 保存训练模型
    def save(self):
        pass  # 把_w和_b保存到文件(pickle)

    def load(self):
        pass


def load_mnist(dataset="training_data", digits=np.arange(10), path="./"):
    if dataset == "training_data":
        fname_image = os.path.join(path+dataset, 'train-images.idx3-ubyte')
        fname_label = os.path.join(path+dataset, 'train-labels.idx1-ubyte')
    elif dataset == "testing_data":
        fname_image = os.path.join(path+dataset, 't10k-images.idx3-ubyte')
        fname_label = os.path.join(path+dataset, 't10k-labels.idx1-ubyte')
    else:
        raise ValueError("dataset must be 'training_data' or 'testing_data'")

    flbl = open(fname_label, 'rb')
    magic_nr, size = struct.unpack(">II", flbl.read(8))
    lbl = pyarray("b", flbl.read())
    flbl.close()

    fimg = open(fname_image, 'rb')
    magic_nr, size, rows, cols = struct.unpack(">IIII", fimg.read(16))
    img = pyarray("B", fimg.read())
    fimg.close()

    ind = [k for k in range(size) if lbl[k] in digits]
    N = len(ind)

    images = zeros((N, rows, cols), dtype=uint8)
    labels = zeros((N, 1), dtype=int8)
    for i in range(len(ind)):
        images[i] = array(img[ind[i] * rows * cols: (ind[i] + 1) * rows * cols]).reshape((rows, cols))
        labels[i] = lbl[ind[i]]

    return images, labels

def load_samples(dataset="training_data"):
    image, label = load_mnist(dataset)

    X = [np.reshape(x, (28 * 28, 1)) for x in image]
    X = [x / 255.0 for x in X]  # 灰度值范围(0-255),转换为(0-1)

    # 5 -> [0,0,0,0,0,1.0,0,0,0];  1 -> [0,1.0,0,0,0,0,0,0,0]
    def vectorized_Y(y):
        e = np.zeros((10, 1))
        e[y] = 1.0
        return e

    if dataset == "training_data":
        Y = [vectorized_Y(y) for y in label]
        pair = list(zip(X, Y))
        return pair
    elif dataset == 'testing_data':
        pair = list(zip(X, label))
        return pair
    else:
        print('Something wrong')


if __name__ == '__main__':
    INPUT = 28 * 28
    OUTPUT = 10
    net = NeuralNet(sizes=[INPUT, 40, OUTPUT])
    train_set = load_samples(dataset='training_data')
    test_set = load_samples(dataset='testing_data')
    net.SGD(train_set, 13, 100, 3.0, test_data=test_set)
    # 准确率
    correct = 0
    for test_feature in test_set:
        if net.predict(test_feature[0]) == test_feature[1][0]:
            correct += 1
    print("准确率: ", correct / len(test_set))

训练大概需要几分钟,执行结果:

使用Python实现神经网络

你可以对神经元数量、训练次数等参数进行调整,准确率应该能达到96%+;和99.8%还有很大差距

  • 使用tensorflow训练MNIST数据
# -*- coding:utf-8 -*-
import tensorflow as tf
import numpy as np
# tensorflow自带了MNIST数据集
from tensorflow.examples.tutorials.mnist import input_data


# 下载mnist数据集
mnist = input_data.read_data_sets('./data', one_hot=True)
# 数字(label)只能是0-9,神经网络使用10个出口节点就可以编码表示0-9;
#  1 -> [0,1.0,0,0,0,0,0,0,0]   one_hot表示只有一个出口节点是hot
#  2 -> [0,0.1,0,0,0,0,0,0,0]
#  5 -> [0,0,0,0,0,1.0,0,0,0]
#  /tmp是macOS的临时目录,重启系统数据丢失; Linux的临时目录也是/tmp

# 定义每个层有多少'神经元''
n_input_layer = 28 * 28  # 输入层
n_layer_1 = 500  # hide layer
n_layer_2 = 1000  # hide layer
n_layer_3 = 300  # hide layer(隐藏层)听着很神秘,其实就是除输入输出层外的中间层
n_output_layer = 10  # 输出层
"""
层数的选择:线性数据使用1层,非线性数据使用2册, 超级非线性使用3+册。层数/神经元 过多会导致过拟合
"""
# 每次使用100条数据进行训练
batch_size = 100

# 定义待训练的神经网络(feedforward)
def neural_network(data):
    # 定义第一层"神经元"的权重和biases
    layer_1_w_b = {'w_': tf.Variable(tf.random_normal([n_input_layer, n_layer_1])),
                   'b_': tf.Variable(tf.random_normal([n_layer_1]))}
    # 定义第二层"神经元"的权重和biases
    layer_2_w_b = {'w_': tf.Variable(tf.random_normal([n_layer_1, n_layer_2])),
                   'b_': tf.Variable(tf.random_normal([n_layer_2]))}
    # 定义第三层"神经元"的权重和biases
    layer_3_w_b = {'w_': tf.Variable(tf.random_normal([n_layer_2, n_layer_3])),
                   'b_': tf.Variable(tf.random_normal([n_layer_3]))}
    # 定义输出层"神经元"的权重和biases
    layer_output_w_b = {'w_': tf.Variable(tf.random_normal([n_layer_3, n_output_layer])),
                        'b_': tf.Variable(tf.random_normal([n_output_layer]))}
    # w·x+b
    layer_1 = tf.add(tf.matmul(data, layer_1_w_b['w_']), layer_1_w_b['b_'])
    layer_1 = tf.nn.relu(layer_1)  # 激活函数
    layer_2 = tf.add(tf.matmul(layer_1, layer_2_w_b['w_']), layer_2_w_b['b_'])
    layer_2 = tf.nn.relu(layer_2)  # 激活函数
    layer_3 = tf.add(tf.matmul(layer_2, layer_3_w_b['w_']), layer_3_w_b['b_'])
    layer_3 = tf.nn.relu(layer_3)  # 激活函数
    layer_output = tf.add(tf.matmul(layer_3, layer_output_w_b['w_']), layer_output_w_b['b_'])

    return layer_output

# 使用数据训练神经网络
def train_neural_network(X, Y):
    predict = neural_network(X)
    cost_func = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(logits=predict,labels=Y))
    optimizer = tf.train.AdamOptimizer(learning_rate=0.001).minimize(loss=cost_func)  # learning rate 默认 0.001

    epochs = 13
    with tf.Session() as session:
        session.run(tf.initialize_all_variables())
        epoch_loss = 0
        for epoch in range(epochs):
            for i in range(int(mnist.train.num_examples / batch_size)):
                x, y = mnist.train.next_batch(batch_size)
                _, c = session.run([optimizer, cost_func], feed_dict={X: x, Y: y})
                epoch_loss += c
            print(epoch, ' : ', epoch_loss)

        # print(predict.eval(feed_dict={X:[features]}))
        correct = tf.equal(tf.argmax(predict, 1), tf.argmax(Y, 1))
        accuracy = tf.reduce_mean(tf.cast(correct, 'float'))
        print('准确率: ', accuracy.eval({X: mnist.test.images, Y: mnist.test.labels}))

X = tf.placeholder('float', [None, 28 * 28])
# [None, 28*28]代表数据数据的高和宽(矩阵),好处是如果数据不符合宽高,tensorflow会报错,不指定也可以。
Y = tf.placeholder('float')
train_neural_network(X, Y)

image.png

  • 使用sklearn的svm分类MNIST数据
# -*- coding:utf-8 -*-
from sklearn import svm
import numpy as np
import os,struct
from array import array as pyarray
from numpy import append, array, int8, uint8, zeros
import pickle


def load_mnist(dataset="training_data", digits=np.arange(10), path="./"):
    if dataset == "training_data":
        fname_image = os.path.join(path+dataset, 'train-images.idx3-ubyte')
        fname_label = os.path.join(path+dataset, 'train-labels.idx1-ubyte')
    elif dataset == "testing_data":
        fname_image = os.path.join(path+dataset, 't10k-images.idx3-ubyte')
        fname_label = os.path.join(path+dataset, 't10k-labels.idx1-ubyte')
    else:
        raise ValueError("dataset must be 'training_data' or 'testing_data'")

    flbl = open(fname_label, 'rb')
    magic_nr, size = struct.unpack(">II", flbl.read(8))
    print(magic_nr, size)
    lbl = pyarray("b", flbl.read())
    print('lbl:',lbl)
    flbl.close()

    fimg = open(fname_image, 'rb')
    magic_nr, size, rows, cols = struct.unpack(">IIII", fimg.read(16))
    print(magic_nr, size, rows, cols)
    img = pyarray("B", fimg.read())
    # print('img:',img)
    fimg.close()

    ind = [k for k in range(size) if lbl[k] in digits]
    N = len(ind)

    images = zeros((N, rows, cols), dtype=uint8)
    labels = zeros((N, 1), dtype=int8)
    for i in range(len(ind)):
        images[i] = array(img[ind[i] * rows * cols: (ind[i] + 1) * rows * cols]).reshape((rows, cols))
        labels[i] = lbl[ind[i]]

    return images, labels

def load_samples(dataset="training_data"):
    image, label = load_mnist(dataset)

    # 把28*28二维数据转为一维数据
    X = [np.reshape(x, (28 * 28)) for x in image]
    X = [x / 255.0 for x in X]  # 灰度值范围(0-255),转换为(0-1)
    # print(X.shape)
    pair = list(zip(X, label))
    return pair


if __name__ == '__main__':
    train_set = load_samples(dataset='training_data')
    test_set = load_samples(dataset='testing_data')
    train_X = []
    train_Y = []
    for feature in train_set:
        train_X.append(feature[0])
        train_Y.append(feature[1][0])

    clf = svm.SVR()
    clf.fit(train_X, train_Y)  # 很耗时(我吃完饭回来,还没完,蛋碎... i5 CPU-8G RAM)
    # with open('minst.module', 'wb') as f:
    # pickle.dump(clf, f)
    # with open('minst.module', 'rb') as f:
    #	clf = pickle.load(f)
    test_X = []
    test_Y = []
    for feature in test_set:
        test_X.append(feature[0])
        test_Y.append(feature[1][0])
    # 准确率
    correct = 0
    i = 0
    for feature in test_X:
        predict = clf.predict(np.array(feature).reshape(1, -1))
        if round(float(predict)) == test_Y[i]:
            correct += 1
        i = i + 1
    print("准确率: ", correct / len(test_X))

执行结果:

准确率:  0.4023

来源:http://blog.topspeedsnail.com/archives/10377

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

[556]python实现神经网络 的相关文章

  • 使用机器学习算法预测航班价格

    一 前言 机票价格的预测一直是航空业和旅行者关注的重要问题之一 随着航空业的快速发展和市场竞争的加剧 正确预测机票价格对于航空公司的利润最大化和旅行者的预算规划至关重要 在过去 人们通常依靠经验和市场趋势来预测机票价格 但这种方法往往存在不
  • Qt宏定义

    1 QT BEGIN NAMESPACE 在qglobal h中 我们可以看到以下两句胡宏定义 define QT BEGIN NAMESPACE namespace QT NAMESPACE define QT END NAMESPACE

随机推荐

  • Java中有关锁的面试题

    sychronized修饰普通方法和静态方法的区别 什么是可见性 对象锁是用于对象实例方法 或者一个对象实例上的 类锁是用于类的静态方法或者一个类的class对象上的 类的对象实例可以有很多个 但是每个类只有一个class对象 所以不同对象
  • 静态成员(static)

    今天整理了一下关于静态的一些知识点 可能有些没有整理到 或者理解有纰漏 大家不妨看看 不足之处 恳请大家斧正 在静态类中 静态类中不能调用非静态类的实例成员 静态类中不能有非静态构造函数 但是可以有静态构造函数 静态构造函数也可以存在于非静
  • D361周赛复盘:模拟分割整数⭐+变为整除的最小次数⭐

    文章目录 2843 统计对称整数的数目 模拟 分割整数为两部分 思路 1 整数换成字符串版本 2 直接用整数的版本 2844 生成特殊数字的最小操作 模拟 x能被Num整除的条件 思路 完整版 2843 统计对称整数的数目 模拟 分割整数为
  • 微信小程序超详细入门简介和使用

    微信小程序 介绍 微信小程序 简称小程序 英文名Mini Program 是一种不需要下载安装即可使用的应用 它实现了应用 触手可及的梦想 用户扫一扫或搜一下即可打开应用 微信小程序做项目的必备基础 小程序的前世今生 小程序开发者工具 小程
  • Chatgpt API调用报错:openai.error.RateLimitError

    Chatgpt API 调用报错 openai error RateLimitError You exceeded your current quota please check your plan and billing details
  • 常用图像增强方法,利用tf.keras来完成图像增强

    学习目标 知道图像增强的常用方法 能够利用tf keras来完成图像增强 大规模数据集是成功应用深度神经网络的前提 例如 我们可以对图像进行不同方式的裁剪 使感兴趣的物体出现在不同位置 从而减轻模型对物体出现位置的依赖性 我们也可以调整亮度
  • allure在python环境下的集成使用

    python环境下 集成allure 首先打开Allure官网 https docs qameta io allure 选择对应平台的安装方式 最下面有通用安装方法 1 去maven central下载一个新版本的zip 2 下载到本地后解
  • 【手写一个RPC框架】simpleRPC-02

    目录 前言 实现 项目创建 依赖配置 common service client server 文件结构 运行 本项目所有代码可见 https github com weiyu zeng SimpleRPC 前言 在simpleRPC 01
  • Flask - 应用上下文

    目录 一 应用上下文 二 current app 在任何地点 获取flask app对象 三 g 单次请求的数据存储字典
  • 关于Unity3D中的Debug类的一些函数内容

    这篇文章主要是我对Debug类中的一些个人理解以及一些Debug的方法 请大家理性阅读 有错误可以私聊本人指出 Unity3DEngine Debug 这中间可能包含了一些常用的debug方法 比如下面这个黑科技 这是我在学习debug类的
  • 实时脑波和眼动连通性分析 python-(3)

    实时提取脑波的delta theta alpha beta 对于baseline的比率差 import os import pandas as pd import numpy as np def mkdir path 3 folder os
  • 使用rke2安装高可用k8s集群

    文章目录 使用rke2安装高可用k8s集群 使用rke2安装高可用k8s集群 服务器rke集群节点角色规划 用户 主机名 内网IP SSH端口 系统 角色 root rke server 01 192 168 2 131 22 CentOS
  • MySql操作笔记(表查看、删除、行数据删除...)

    1 显示表的结构 1 desc table name 2 describe table name 3 show columns from table name 2 显示表中所有内容 select from table name 3 行数据删
  • RS232以及RS485的一些理解

    今天 在吾爱PLC网站上阅读了关于PLC通讯的相关知识 讲得十分详细 之前一直搞不懂RS232协议 RS485协议 MODBUS协议 通过前几天在十堰的实习 在口罩生产线上的对嵌入式板卡与伺服驱动器以及HMI的连接时 查阅了一些关于通讯的知
  • C++中构造函数调用其他函数

    include
  • TTMS课程设计 管理员板块 前端页面+使用技术总结

    文章目录 一 部分实现效果 二 使用技术 三 主要代码 1 jq ajax提交表单数据 2 数据分页 3 省市区三级联动 4 选择日期 5 渲染数据 6 Session Storage在页面存储数据 7 使用es6模板字符串 四 总结 1
  • 1.数字图像识别

    传送门 https www lintcode com ai digit recognition overview 题目描述 MNIST是计算机视觉领域的 hello world 数据集 自1999年发布以来 这种手写图像的经典数据集已经成为
  • CV计算机视觉核心09-图像分割FCN(Penn-Fudan Database数据集)

    CV计算机视觉核心09 图像分割FCN Penn Fudan Database数据集 Penn Fudan Database数据集下载地址 https www cis upenn edu jshi ped html 1 首先读取数据 Pen
  • 【错误解决】git报错:you are not allowed to push code to protected branches on this project

    场景回忆 本地修改需要退回到之前的版本 打算强制push本地版本覆盖远程版本 但是在git push force后出现了以下的错误 Fix GitLab error you are not allowed to push code to p
  • [556]python实现神经网络

    神经网络 人工神经网络的洋文是Neural Network 这个计算模型在上世纪40年代就出现了 但是直到2011 2012年由于大数据和深度学习的兴起 神经网络才得到广泛应用 参看wiki神经网络 https en wikipedia o