神经网络代码实现

目录

神经网络整体框架

核心计算步骤

参数初始化

 矩阵拉伸与还原

前向传播

损失函数定义

反向传播

全部迭代更新完成

数字识别实战

神经网络整体框架

核心计算步骤

参数初始化

# 定义初始化函数   normalize_data是否需要标准化
    def __init__(self,data,labels,layers,normalize_data=False):
        # 数据处理
        data_procesed = prepare_for_training(data,normalize_data = normalize_data)
        # 获取当前处理好的数据
        self.data = data_procesed
        self.labels = labels
        # 定义神经网络层数
        self.layers = layers #784(28*28*1)| 像素点 25(隐层神经元)| 10(十分类任务)
        self.normalize_data = normalize_data
        # 初始化权重参数
        self.thetas = MultilayerPerceptron.thetas_init(layers)

    @staticmethod
    def thetas_init(layers):
        # 层的个数
        num_layers = len(layers)
        # 构建多组权重参数
        thetas = {}
        # 会执行两次,得到两组参数矩阵:25*785 , 10*26
        for layer_index in range(num_layers - 1):
            # 输入
            in_count = layers[layer_index] #784
            # 输出
            out_count = layers[layer_index+1]
            # 构建矩阵并初始化操作 随机进行初始化操作,值尽量小一点
            thetas[layer_index] = np.random.rand(out_count,in_count+1)*0.05 # WX in_count+1:偏置项考虑进去,偏置项个数跟输出的结果一致
            return thetas

 矩阵拉伸与还原

 
# 将25*785矩阵拉长1*19625
    @staticmethod
    def thetas_unroll(thetas):
        num_theta_layers = len(thetas) #25*785 , 10*26;num_theta_layers长度为2
        unrolled_theta = np.array([])
        for theta_layer_index in range(num_theta_layers):
            # thetas[theta_layer_index].flatten()矩阵拉长
            # np.hstack((unrolled_theta, thetas[theta_layer_index].flatten())) 数组拼接 将25*785 , 10*26两个矩阵拼接成一个 1*x的矩阵
            unrolled_theta = np.hstack((unrolled_theta, thetas[theta_layer_index].flatten()))
        return unrolled_theta
# 矩阵还原
    """
    将展开的`unrolled_thetas`重新组织成一个字典`thetas`,其中每个键值对表示一个层的权重阵。
    函数的输入参数包括展开的参数`unrolled_thetas`和神经网络的层结构`layers`。
    具体来说,函数首先获取层的数量`num_layers`,然后创建一个空字典`thetas`用于存储权重矩阵。
    接下来,函数通过循环遍历每一层(除了最后一层),并根据层的输入和输出节点数计算权重矩阵的大小。
    在循环中,函数首先计算当前层权重矩阵的宽度`thetas_width`和高度`thetas_height`,
    然后计算权重矩阵的总元素个数`thetas_volume`。
    接着,函数根据展开参数的索引范围提取对应层的展开权重,并通过`reshape`函数将展开权重重新组织成一个二维矩阵。
    最后,函数将该矩阵存储到字典`thetas`中,键为当前层的索引。
    循环结束后,函数返回字典`thetas`,其中包含了每一层的权重矩阵。
    """
    @staticmethod
    def thetas_roll(unrolled_thetas,layers):
        # 进行反变换,将行转换为矩阵
        num_layers = len(layers)
        # 包含第一层、第二层、第三层
        thetas = {}
        # 指定标识符当前变换到哪了
        unrolled_shift = 0
        # 构造想要的参数矩阵
        for layer_index in range(num_layers - 1):
            # 输入
            in_count = layers[layer_index]
            # 输出
            out_count = layers[layer_index + 1]
            # 构造矩阵
            thetas_width = in_count + 1
            thetas_height = out_count
            # 计算权重矩阵的总元素个数
            thetas_volume = thetas_width * thetas_height
            # 指定从矩阵中哪个位置取值
            start_index = unrolled_shift
            # 结束位置
            end_index = unrolled_shift + thetas_volume
            layer_theta_unrolled = unrolled_thetas[start_index:end_index]
            # 获得25*785和10*26两个矩阵
            thetas[layer_index] = layer_theta_unrolled.reshape((thetas_height, thetas_width))
            # 更新
            unrolled_shift = unrolled_shift + thetas_volume
        return thetas

前向传播

# 前向传播函数
    @staticmethod
    def feedforward_propagation(data,thetas,layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数
        num_examples = data.shape[0]
        # 定义输入层
        in_layer_activation = data
        # 逐层计算
        for layer_index in range(num_layers - 1):
            theta = thetas[layer_index]
            # 隐藏层得到的结果
            out_layer_activation = sigmoid(np.dot(in_layer_activation, theta.T))
            # 正常计算完之后是num_examples*25,但是要考虑偏置项 变成num_examples*26
            out_layer_activation = np.hstack((np.ones((num_examples, 1)), out_layer_activation))
            in_layer_activation = out_layer_activation
        # 返回输出层结果,结果中不要偏置项了
        return in_layer_activation[:, 1:]

损失函数定义

# 损失函数定义
    @staticmethod
    def cost_function(data,labels,thetas,layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数
        num_examples = data.shape[0]
        # 分类个数
        num_labels = layers[-1]
        # 前向传播走一次
        predictions = MultilayerPerceptron.feedforward_propagation(data, thetas, layers)
        # 制作标签,每一个样本的标签都得是one-hot
        bitwise_labels = np.zeros((num_examples, num_labels))
        for example_index in range(num_examples):
            # 将对应的位置改为 1
            bitwise_labels[example_index][labels[example_index][0]] = 1
        # 计算损失
        bit_set_cost = np.sum(np.log(predictions[bitwise_labels == 1]))
        bit_not_set_cost = np.sum(np.log(1 - predictions[bitwise_labels == 0]))
        cost = (-1 / num_examples) * (bit_set_cost + bit_not_set_cost)
        return cost

反向传播

# 反向传播函数
    @staticmethod
    def back_propagation(data, labels, thetas, layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数、特征个数
        (num_examples, num_features) = data.shape
        # 输出结果
        num_label_types = layers[-1]
        # 输出层跟结果之间的差异
        deltas = {}
        # 初始化操作 逐层定义当前的值
        for layer_index in range(num_layers - 1):
            in_count = layers[layer_index]
            out_count = layers[layer_index + 1]
            # 构建矩阵
            deltas[layer_index] = np.zeros((out_count, in_count + 1))  # 得到两个矩阵25*785 10*26
        # 遍历输入层每个样本
        for example_index in range(num_examples):
            # 得到每层的输出结果
            layers_inputs = {}
            layers_activations = {}
            # 第0层输入转换为向量个数 输入层结果
            layers_activation = data[example_index, :].reshape((num_features, 1))  # 785*1
            layers_activations[0] = layers_activation
            # 逐层计算
            for layer_index in range(num_layers - 1):
                layer_theta = thetas[layer_index]  # 得到当前权重参数值 25*785   10*26
                layer_input = np.dot(layer_theta, layers_activation)  # 第一次得到25*1 第二次10*1 第一层输出等于第二层输入
                layers_activation = np.vstack((np.array([[1]]), sigmoid(layer_input)))
                layers_inputs[layer_index + 1] = layer_input  # 后一层计算结果
                layers_activations[layer_index + 1] = layers_activation  # 后一层经过激活函数后的结果
            output_layer_activation = layers_activation[1:, :] #去除偏置参数

            delta = {}
            # 标签处理
            bitwise_label = np.zeros((num_label_types, 1))
            bitwise_label[labels[example_index][0]] = 1
            # 计算输出层和真实值之间的差异
            delta[num_layers - 1] = output_layer_activation - bitwise_label

            # 遍历循环 L L-1 L-2 ...2
            for layer_index in range(num_layers - 2, 0, -1):
                layer_theta = thetas[layer_index]
                next_delta = delta[layer_index + 1]
                layer_input = layers_inputs[layer_index]
                layer_input = np.vstack((np.array((1)), layer_input))
                # 按照公式进行计算
                delta[layer_index] = np.dot(layer_theta.T, next_delta) * sigmoid_gradient(layer_input)
                # 过滤掉偏置参数
                delta[layer_index] = delta[layer_index][1:, :]
            # 梯度值计算
            for layer_index in range(num_layers - 1):
                layer_delta = np.dot(delta[layer_index + 1], layers_activations[layer_index].T)
                deltas[layer_index] = deltas[layer_index] + layer_delta  # 第一次25*785  第二次10*26

        for layer_index in range(num_layers - 1):
            deltas[layer_index] = deltas[layer_index] * (1 / num_examples)

        return deltas

全部迭代更新完成

import numpy as np
from utils.features import prepare_for_training
from utils.hypothesis import sigmoid,sigmoid_gradient

class MultilayerPerceptron:
    # 定义初始化函数   normalize_data是否需要标准化
    def __init__(self,data,labels,layers,normalize_data=False):
        # 数据处理
        data_procesed = prepare_for_training(data,normalize_data = normalize_data)
        # 获取当前处理好的数据
        self.data = data_procesed
        self.labels = labels
        # 定义神经网络层数
        self.layers = layers #784(28*28*1)| 像素点 25(隐层神经元)| 10(十分类任务)
        self.normalize_data = normalize_data
        # 初始化权重参数
        self.thetas = MultilayerPerceptron.thetas_init(layers)

    @staticmethod
    def thetas_init(layers):
        # 层的个数
        num_layers = len(layers)
        # 构建多组权重参数
        thetas = {}
        # 会执行两次,得到两组参数矩阵:25*785 , 10*26
        for layer_index in range(num_layers - 1):
            # 输入
            in_count = layers[layer_index] #784
            # 输出
            out_count = layers[layer_index+1]
            # 构建矩阵并初始化操作 随机进行初始化操作,值尽量小一点
            thetas[layer_index] = np.random.rand(out_count,in_count+1)*0.05 # WX in_count+1:偏置项考虑进去,偏置项个数跟输出的结果一致
            return thetas

    # 将25*785矩阵拉长1*19625
    @staticmethod
    def thetas_unroll(thetas):
        num_theta_layers = len(thetas) #25*785 , 10*26;num_theta_layers长度为2
        unrolled_theta = np.array([])
        for theta_layer_index in range(num_theta_layers):
            # thetas[theta_layer_index].flatten()矩阵拉长
            # np.hstack((unrolled_theta, thetas[theta_layer_index].flatten())) 数组拼接 将25*785 , 10*26两个矩阵拼接成一个 1*x的矩阵
            unrolled_theta = np.hstack((unrolled_theta, thetas[theta_layer_index].flatten()))
        return unrolled_theta

    # 矩阵还原
    """
    将展开的`unrolled_thetas`重新组织成一个字典`thetas`,其中每个键值对表示一个层的权重阵。
    函数的输入参数包括展开的参数`unrolled_thetas`和神经网络的层结构`layers`。
    具体来说,函数首先获取层的数量`num_layers`,然后创建一个空字典`thetas`用于存储权重矩阵。
    接下来,函数通过循环遍历每一层(除了最后一层),并根据层的输入和输出节点数计算权重矩阵的大小。
    在循环中,函数首先计算当前层权重矩阵的宽度`thetas_width`和高度`thetas_height`,
    然后计算权重矩阵的总元素个数`thetas_volume`。
    接着,函数根据展开参数的索引范围提取对应层的展开权重,并通过`reshape`函数将展开权重重新组织成一个二维矩阵。
    最后,函数将该矩阵存储到字典`thetas`中,键为当前层的索引。
    循环结束后,函数返回字典`thetas`,其中包含了每一层的权重矩阵。
    """
    @staticmethod
    def thetas_roll(unrolled_thetas,layers):
        # 进行反变换,将行转换为矩阵
        num_layers = len(layers)
        # 包含第一层、第二层、第三层
        thetas = {}
        # 指定标识符当前变换到哪了
        unrolled_shift = 0
        # 构造想要的参数矩阵
        for layer_index in range(num_layers - 1):
            # 输入
            in_count = layers[layer_index]
            # 输出
            out_count = layers[layer_index + 1]
            # 构造矩阵
            thetas_width = in_count + 1
            thetas_height = out_count
            # 计算权重矩阵的总元素个数
            thetas_volume = thetas_width * thetas_height
            # 指定从矩阵中哪个位置取值
            start_index = unrolled_shift
            # 结束位置
            end_index = unrolled_shift + thetas_volume
            layer_theta_unrolled = unrolled_thetas[start_index:end_index]
            # 获得25*785和10*26两个矩阵
            thetas[layer_index] = layer_theta_unrolled.reshape((thetas_height, thetas_width))
            # 更新
            unrolled_shift = unrolled_shift + thetas_volume
        return thetas

    # 损失函数定义
    @staticmethod
    def cost_function(data,labels,thetas,layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数
        num_examples = data.shape[0]
        # 分类个数
        num_labels = layers[-1]
        # 前向传播走一次
        predictions = MultilayerPerceptron.feedforward_propagation(data, thetas, layers)
        # 制作标签,每一个样本的标签都得是one-hot
        bitwise_labels = np.zeros((num_examples, num_labels))
        for example_index in range(num_examples):
            # 将对应的位置改为 1
            bitwise_labels[example_index][labels[example_index][0]] = 1
        # 计算损失
        bit_set_cost = np.sum(np.log(predictions[bitwise_labels == 1]))
        bit_not_set_cost = np.sum(np.log(1 - predictions[bitwise_labels == 0]))
        cost = (-1 / num_examples) * (bit_set_cost + bit_not_set_cost)
        return cost

    # 梯度值计算函数
    @staticmethod
    def gradient_step(data, labels, optimized_theta, layers):
        # 将theta值还原成矩阵格式
        theta = MultilayerPerceptron.thetas_roll(optimized_theta, layers)
        # 反向传播
        thetas_rolled_gradients = MultilayerPerceptron.back_propagation(data, labels, theta, layers)
        # 将矩阵拉伸方便参数更新
        thetas_unrolled_gradients = MultilayerPerceptron.thetas_unroll(thetas_rolled_gradients)
        # 返回梯度值
        return thetas_unrolled_gradients

    # 梯度下降模块
    @staticmethod
    def gradient_descent(data,labels,unrolled_theta,layers,max_iterations,alpha):
        # 最终得到的theta值先使用初始theta
        optimized_theta = unrolled_theta
        # 每次迭代都会得到当前的损失值,记录到 cost_history数组中
        cost_history = []
        # 进行迭代
        for _ in range(max_iterations):
            # 1.计算当前损失值  thetas_roll()函数将拉长后的向量还原成矩阵
            cost = MultilayerPerceptron.cost_function(data, labels,
                                                      MultilayerPerceptron.thetas_roll(optimized_theta, layers), layers)
            # 记录当前损失
            cost_history.append(cost)
            # 2.根据损失值计算当前梯度值
            theta_gradient = MultilayerPerceptron.gradient_step(data, labels, optimized_theta, layers)
            # 3.更新梯度值,最终得到的结果是优化完的theta
            optimized_theta = optimized_theta - alpha * theta_gradient
        return optimized_theta, cost_history

    # 前向传播函数
    @staticmethod
    def feedforward_propagation(data,thetas,layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数
        num_examples = data.shape[0]
        # 定义输入层
        in_layer_activation = data
        # 逐层计算
        for layer_index in range(num_layers - 1):
            theta = thetas[layer_index]
            # 隐藏层得到的结果
            out_layer_activation = sigmoid(np.dot(in_layer_activation, theta.T))
            # 正常计算完之后是num_examples*25,但是要考虑偏置项 变成num_examples*26
            out_layer_activation = np.hstack((np.ones((num_examples, 1)), out_layer_activation))
            in_layer_activation = out_layer_activation
        # 返回输出层结果,结果中不要偏置项了
        return in_layer_activation[:, 1:]

    # 反向传播函数
    @staticmethod
    def back_propagation(data, labels, thetas, layers):
        # 获取层数
        num_layers = len(layers)
        # 样本个数、特征个数
        (num_examples, num_features) = data.shape
        # 输出结果
        num_label_types = layers[-1]
        # 输出层跟结果之间的差异
        deltas = {}
        # 初始化操作 逐层定义当前的值
        for layer_index in range(num_layers - 1):
            in_count = layers[layer_index]
            out_count = layers[layer_index + 1]
            # 构建矩阵
            deltas[layer_index] = np.zeros((out_count, in_count + 1))  # 得到两个矩阵25*785 10*26
        # 遍历输入层每个样本
        for example_index in range(num_examples):
            # 得到每层的输出结果
            layers_inputs = {}
            layers_activations = {}
            # 第0层输入转换为向量个数 输入层结果
            layers_activation = data[example_index, :].reshape((num_features, 1))  # 785*1
            layers_activations[0] = layers_activation
            # 逐层计算
            for layer_index in range(num_layers - 1):
                layer_theta = thetas[layer_index]  # 得到当前权重参数值 25*785   10*26
                layer_input = np.dot(layer_theta, layers_activation)  # 第一次得到25*1 第二次10*1 第一层输出等于第二层输入
                layers_activation = np.vstack((np.array([[1]]), sigmoid(layer_input)))
                layers_inputs[layer_index + 1] = layer_input  # 后一层计算结果
                layers_activations[layer_index + 1] = layers_activation  # 后一层经过激活函数后的结果
            output_layer_activation = layers_activation[1:, :] #去除偏置参数

            delta = {}
            # 标签处理
            bitwise_label = np.zeros((num_label_types, 1))
            bitwise_label[labels[example_index][0]] = 1
            # 计算输出层和真实值之间的差异
            delta[num_layers - 1] = output_layer_activation - bitwise_label

            # 遍历循环 L L-1 L-2 ...2
            for layer_index in range(num_layers - 2, 0, -1):
                layer_theta = thetas[layer_index]
                next_delta = delta[layer_index + 1]
                layer_input = layers_inputs[layer_index]
                layer_input = np.vstack((np.array((1)), layer_input))
                # 按照公式进行计算
                delta[layer_index] = np.dot(layer_theta.T, next_delta) * sigmoid_gradient(layer_input)
                # 过滤掉偏置参数
                delta[layer_index] = delta[layer_index][1:, :]
            # 梯度值计算
            for layer_index in range(num_layers - 1):
                layer_delta = np.dot(delta[layer_index + 1], layers_activations[layer_index].T)
                deltas[layer_index] = deltas[layer_index] + layer_delta  # 第一次25*785  第二次10*26

        for layer_index in range(num_layers - 1):
            deltas[layer_index] = deltas[layer_index] * (1 / num_examples)

        return deltas


    # 定义训练模块      定义最大迭代次数    定义学习率
    def train(self,max_iterations=1000,alpha=0.1):
        """第一步首先需要做优化,计算损失函数然后根据损失函数计算梯度值,
        然后更新梯度值调整权重参数,前向传播加反向传播,整体一次迭代"""
        # 将矩阵转化为向量方便参数更新,将25*785矩阵拉长1*19625
        unrolled_theta = MultilayerPerceptron.thetas_unroll(self.thetas)
        # 梯度下降模块
        (optimized_theta, cost_history) = MultilayerPerceptron.gradient_descent(self.data, self.labels, unrolled_theta,
                                                                                self.layers, max_iterations, alpha)
        # 参数更新完成之后需要将拉长后的还原,进行前向传播
        self.thetas = MultilayerPerceptron.thetas_roll(optimized_theta, self.layers)
        return self.thetas, cost_history

数字识别实战

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as mping 
import math

from multilayer_perceptron import MultilayerPerceptron


data = pd.read_csv('../data/mnist-demo.csv')
numbers_to_display = 25
num_cells = math.ceil(math.sqrt(numbers_to_display))
plt.figure(figsize=(10,10))
for plot_index in range(numbers_to_display):
    digit = data[plot_index:plot_index+1].values
    digit_label = digit[0][0]
    digit_pixels = digit[0][1:]
    image_size = int(math.sqrt(digit_pixels.shape[0]))
    frame = digit_pixels.reshape((image_size,image_size))
    plt.subplot(num_cells,num_cells,plot_index+1)
    plt.imshow(frame,cmap='Greys')
    plt.title(digit_label)
plt.subplots_adjust(wspace=0.5,hspace=0.5)
plt.show()

train_data = data.sample(frac = 0.8)
test_data = data.drop(train_data.index)

train_data = train_data.values
test_data = test_data.values

num_training_examples = 1700

x_train = train_data[:num_training_examples,1:]
y_train = train_data[:num_training_examples,[0]]

x_test = test_data[:,1:]
y_test = test_data[:,[0]]


layers=[784,25,10]

normalize_data = True
max_iterations = 300
alpha = 0.1


multilayer_perceptron = MultilayerPerceptron(x_train,y_train,layers,normalize_data)
(thetas,costs) = multilayer_perceptron.train(max_iterations,alpha)
plt.plot(range(len(costs)),costs)
plt.xlabel('Grident steps')
plt.xlabel('costs')
plt.show()


y_train_predictions = multilayer_perceptron.predict(x_train)
y_test_predictions = multilayer_perceptron.predict(x_test)

train_p = np.sum(y_train_predictions == y_train)/y_train.shape[0] * 100
test_p = np.sum(y_test_predictions == y_test)/y_test.shape[0] * 100
print ('训练集准确率:',train_p)
print ('测试集准确率:',test_p)

numbers_to_display = 64

num_cells = math.ceil(math.sqrt(numbers_to_display))

plt.figure(figsize=(15, 15))

for plot_index in range(numbers_to_display):
    digit_label = y_test[plot_index, 0]
    digit_pixels = x_test[plot_index, :]

    predicted_label = y_test_predictions[plot_index][0]

    image_size = int(math.sqrt(digit_pixels.shape[0]))

    frame = digit_pixels.reshape((image_size, image_size))

    color_map = 'Greens' if predicted_label == digit_label else 'Reds'
    plt.subplot(num_cells, num_cells, plot_index + 1)
    plt.imshow(frame, cmap=color_map)
    plt.title(predicted_label)
    plt.tick_params(axis='both', which='both', bottom=False, left=False, labelbottom=False, labelleft=False)

plt.subplots_adjust(hspace=0.5, wspace=0.5)
plt.show()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/393848.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Vue3快速上手(七) ref和reactive对比

一、ref和reactive对比 表格形式更加直观吧: 项目refreactive是否支持基本类型支持不支持是否支持对象类型支持支持对象类型是否支持属性直接赋值不支持,需要.value支持是否支持直接重新分配对象支持,因为操作的.value不支持,需…

2022长安杯复现

案件情况 某地警方接到受害人报案称其在某虚拟币交易网站遭遇诈骗,该网站号称使用“USTD 币”购买所谓的“HT 币”,受害人充 值后不但“HT 币”无法提现、交易,而且手机还被恶意软件锁定 勒索。警方根据受害人提供的虚拟币交易网站调取了对应…

类(接口)图几种箭头含义

导语 在平时的开发中,难免会遇到画UML图的时候,也就是我们所说的类图,但是UML图中的箭头多种多样,所代表的含义也是各不相同,今天我们就来说说这几种箭头所代表的含义。 1 泛化 概念:泛化表示一个更泛化的元…

K8S之运用污点、容忍度设置Pod的调度约束

污点、容忍度 污点容忍度 taints 是键值数据,用在节点上,定义污点; tolerations 是键值数据,用在pod上,定义容忍度,能容忍哪些污点。 污点 污点是定义在k8s集群的节点上的键值属性数据,可以决…

Android 15 第一个开发者预览版

点击查看:first-developer-preview-android15 点击查看:Get Android 15 2024年2月16日,谷歌发布 Android 15 第一个开发者预览版 翻译 由工程副总裁戴夫伯克发布 今天,我们发布了Android 15的首个开发者预览版,这样我们的开发者就…

软件测试理论

一、软件测试分类 1.按测试阶段划分 单元测试(模块测试) 针对软件设计中的最小单位(程序模块),进行正确性检查的测试工作。单元测试需要从程序内部结构出发设计测试用例。多个模块可以平行的独立进行单元测试。 单元…

挑战杯 地铁大数据客流分析系统 设计与实现

文章目录 1 前言1.1 实现目的 2 数据集2.2 数据集概况2.3 数据字段 3 实现效果3.1 地铁数据整体概况3.2 平均指标3.3 地铁2018年9月开通运营的线路3.4 客流量相关统计3.4.1 线路客流量排行3.4.2 站点客流量排行3.4.3 入站客流排行3.4.4 整体客流随时间变化趋势3.4.5 不同线路客…

用Locust做性能测试是一种什么样的体验

01 Locust介绍 Locust 一个开源性能测试工具,使用Python代码来定义用户行为,用它可以模拟百万计的并发用户访问你的系统。 性能工具对比: LoadRunner 是非常有名的商业性能测试工具,功能非常强大。使用也比较复杂,目…

【软考中级备考笔记】数据的表示和校验码

2024/2/18 – 数据的表示和校验码 天气:阴雨 春节假期结束后第一个工作日,开始备考中级软件工程师。 希望在今年5月底的软考中取得中级证书 视频地址:https://www.bilibili.com/video/BV1Qc411G7fB 1. 计算机的总体架构 从下图中可以看出&am…

【网站项目】155在线考试与学习交流网页平台

🙊作者简介:拥有多年开发工作经验,分享技术代码帮助学生学习,独立完成自己的项目或者毕业设计。 代码可以私聊博主获取。🌹赠送计算机毕业设计600个选题excel文件,帮助大学选题。赠送开题报告模板&#xff…

RocketMQ订阅关系不一致和不能消费时如何排查?

订阅关系不一致 调整任意一个实例的订阅关系和另一个保持一致 消费者不能消费消息 它是最常见的问题之一,也是每个消息队列服务都会遇到的问题 1.确认哪个消息未消费。在这时消费者至少需要手机消息id、消息key、消息发送时间段三者之一 2.确认消息是否发送成功…

6.s081 学习实验记录(九)lock parallelism

文章目录 一、Memory allocator简介提示实验代码实验结果 二、Buffer cache简介提示实验代码实验结果 该实验将重构某些代码以提高并发度。 首先切换到lock分支: git fetchgit checkout lockmake clean 一、Memory allocator 简介 user/kalloctest 这个程序会对…

安装 Windows 7

1.镜像安装 镜像安装:安装Windows 7 2.安装过程(直接以图的形式呈现) 等待安装成功即可

2.18作业

通过字符设备驱动分步注册过程实现LED驱动的编写,编写应用程序测试 头文件 #ifndef __HEAD_H__ #define __HEAD_H__ typedef struct{unsigned int MODER;unsigned int OTYPER;unsigned int OSPEEDR;unsigned int PUPDR;unsigned int IDR;unsigned int ODR; }gpio…

Jetpack Compose 第 1 课:可组合函数

点击查看:Jetpack Compose 教程 点击查看:Composetutorial 代码 简介 Jetpack Compose 是用于构建原生 Android 界面的新工具包。它使用更少的代码、强大的工具和直观的 Kotlin API,可以帮助您简化并加快 Android 界面开发。 在本教程中&a…

视觉开发板—K210自学笔记(五)--按键控制LED

本期我们来遵循其他单片机的学习路线开始去用板子上的按键控制点亮LED。那么第一步还是先知道K210里面的硬件电路是怎么连接的,需要查看第二节的文档,看看开发板原理图到底是按键是跟哪个IO连在一起。然后再建立输入按键和GPIO的映射就可以开始变成了。 …

Instagram 账号被封怎么办?如何申诉拿回账号?

不知道各位在玩转海外社媒平台时有没有遇到过Instagram账号异常的情况,比如会出现账号受限、帖子发不出去、账号被封号等情况?Instagram账号如果被封不用马上弃用,我们可以先尝试一下申诉,看看能不能把账号解封。所以今天将会出一篇Instagra…

综合布线实训室建设方案2024

综合布线实训室概述 随着智慧城市的发展,人工智能、物联网、云计算、大数据等新鲜行业的兴起,网络布线系统是现代智慧城市、智慧社区、智能建筑、智能家居、智能工厂和现代服务业的基础设施和神经网络,实践表明网络系统的故障 70%发生在布线…

生成式 AI - Diffusion 模型的数学原理(4)

来自 论文《 Denoising Diffusion Probabilistic Model》(DDPM) 论文链接: https://arxiv.org/abs/2006.11239 Hung-yi Lee 课件整理 文章目录 一、 q ( x t ∣ x t − 1 ) q(x_{t} \mid x_{t-1} &#xff…

JVM常见问题笔记分享

文章目录 1 JVM组成1.1 JVM由那些部分组成,运行流程是什么?1.2 什么是程序计数器?1.3 你能给我详细的介绍Java堆吗?元空间(MetaSpace)介绍 1.4 什么是虚拟机栈1.5 堆和栈的区别1.6 能不能解释一下方法区?1.5.1 概述1.5.2 常量池1…