用Tensorflow实现AlexNet识别猫狗数据集(猫狗大战)【附代码】

article/2025/7/10 9:20:16

AlexNet识别猫狗数据集

  • 一、下载猫狗数据集
  • 二、AlexNet实现
    • 1、划分训练集和测试集
    • 2、将训练集和测试集图片放缩为224x224
    • 3、AlexNet实现
    • 4、训练过程
    • 5、模型测试
  • 三、总结

一、下载猫狗数据集

百度云链接如下
链接:https://pan.baidu.com/s/1KWYrGVVS6He7lO7skyhgQQ
提取码:p2dd

二、AlexNet实现

1、划分训练集和测试集

因为猫狗大战的测试集没有label所以说我们就从训练集中抽取20%作为测试集,代码如下图所示
divide.py

import os, random, shutil
def moveFile(fileDir):pathDir = os.listdir(fileDir)    #取图片的原始路径filenumber=len(pathDir)rate=0.2    #自定义抽取图片的比例,比方说100张抽10张,那就是0.1picknumber=int(filenumber*rate) #按照rate比例从文件夹中取一定数量图片sample = random.sample(pathDir, picknumber)  #随机选取picknumber数量的样本图片print (sample)for name in sample:shutil.move(fileDir+name, tarDir+name)returnif __name__ == '__main__':fileDir = "D:\\神经网络\\Alexnet\猫狗数据集\\train\\"    #源图片文件夹路径tarDir = 'D:\\神经网络\\Alexnet\\猫狗数据集\\test\\'    #移动到新的文件夹路径moveFile(fileDir)

按照代码将训练集抽出20%作为测试集,在我们的目录中要有源文件夹train,里面存放的是训练数据集,还要有一个空文件夹test,用来存放从训练集转移过来的测试集,这里用的是交叉验证法。

2、将训练集和测试集图片放缩为224x224

我刚开始训练的时候没有把训练集和测试集的图片规范化化为224x224,导致我测试的时候精度只有70%-80%,后来我寻找原因,把训练时候的图片截取出来,发现大部分训练集的图片在训练时候被reshape为224x224导致图片只被截取了一部分,比如说有的图片只有一条猫腿,所以这样训练肯定是不行的,将图片预处理之后,精度得到了显著的提高

reshape.py
import cv2
import os
def rebuild(file_dir, save_dir):""" 将图片尺寸resize为224*224 """print('Start to resize images...')for file in os.listdir(file_dir):file_path = os.path.join(file_dir, file)try:image = cv2.imread(file_path)image_resized = cv2.resize(image, (224, 224))save_path = save_dir + filecv2.imwrite(save_path, image_resized)except:print(file_path)os.remove(file_path)print('Finished!')rebuild('./train','./finaltrain/')
##./train代表初始训练集的地址,./finaltrain代表预处理之后图片存放的地址

将训练集预处理之后,同样方法预处理测试集

3、AlexNet实现

input_data.py

import tensorflow as tf
import os 
import numpy as np
def get_files(file_dir):cats = []label_cats = []dogs = []label_dogs = []for file in os.listdir(file_dir):name = file.split(sep='.')if 'cat' in name[0]:cats.append(file_dir + file)label_cats.append(0)else:if 'dog' in name[0]:dogs.append(file_dir + file)label_dogs.append(1)image_list = np.hstack((cats,dogs))label_list = np.hstack((label_cats,label_dogs))#print('There are %d cats\nThere are %d dogs' %(len(cats), len(dogs)))# 多个种类分别的时候需要把多个种类放在一起,打乱顺序,这里不需要# 把标签和图片都放倒一个 temp 中 然后打乱顺序,然后取出来temp = np.array([image_list,label_list])temp = temp.transpose()# 打乱顺序np.random.shuffle(temp)# 取出第一个元素作为 image 第二个元素作为 labelimage_list = list(temp[:,0])label_list = list(temp[:,1])label_list = [int(i) for i in label_list]  return image_list,label_list# image_W ,image_H 指定图片大小,batch_size 每批读取的个数 ,capacity队列中 最多容纳元素的个数
def get_batch(image,label,image_W,image_H,batch_size,capacity):# 转换数据为 ts 能识别的格式image = tf.cast(image,tf.string)label = tf.cast(label, tf.int32)# 将image 和 label 放倒队列里 input_queue = tf.train.slice_input_producer([image,label])label = input_queue[1]# 读取图片的全部信息image_contents = tf.read_file(input_queue[0])# 把图片解码,channels =3 为彩色图片, r,g ,b  黑白图片为 1 ,也可以理解为图片的厚度image = tf.image.decode_jpeg(image_contents,channels =3)# 将图片以图片中心进行裁剪或者扩充为 指定的image_W,image_Himage = tf.image.resize_image_with_crop_or_pad(image, image_W, image_H)# 对数据进行标准化,标准化,就是减去它的均值,除以他的方差image = tf.image.per_image_standardization(image)# 生成批次  num_threads 有多少个线程根据电脑配置设置  capacity 队列中 最多容纳图片的个数  tf.train.shuffle_batch 打乱顺序,image_batch, label_batch = tf.train.batch([image, label],batch_size = batch_size, num_threads = 64, capacity = capacity)# 重新定义下 label_batch 的形状label_batch = tf.reshape(label_batch , [batch_size])# 转化图片image_batch = tf.cast(image_batch,tf.float32)return  image_batch, label_batchdef one_hot(labels):'''one-hot 编码'''n_sample=len(labels)n_class=max(labels)+1onehot_labels=np.zeros((n_sample,n_class))onehot_labels[np.arange(n_sample),labels]=1return onehot_labels'''

这个文件的作用是获取训练用的一个batch。

AlexNet.py

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import time
#import creat_and_read_TFReacod as reader
import os
import input_data
os.environ['CUDA_VISIBLE_DEVICES'] = '0'  #这步代表的是采用第一块GPU
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.InteractiveSession(config=config)
train_dir = 'D:\\神经网络\\Alexnet\\猫狗数据集\\train\\'#训练集的地址
#这两步是获取batch
x_train,y_train=input_data.get_files(train_dir)  
image_batch,label_batch=input_data.get_batch(x_train,y_train,227,227,50,2048)#Batch_Normalization正则化,这一步规范化处理相当重要,
#经过我的实验发现,如果不经过规范化处理,都很难达到收敛,这一开始困扰了我很长时间
def batch_norm(inputs,is_train,is_conv_out=True,decay=0.999):scale=tf.Variable(tf.ones([inputs.get_shape()[-1]]))beta = tf.Variable(tf.zeros([inputs.get_shape()[-1]]))pop_mean = tf.Variable(tf.zeros([inputs.get_shape()[-1]]), trainable=False)pop_var = tf.Variable(tf.ones([inputs.get_shape()[-1]]), trainable=False)if is_train:if is_conv_out:batch_mean, batch_var = tf.nn.moments(inputs, [0, 1, 2])else:batch_mean, batch_var = tf.nn.moments(inputs, [0])train_mean = tf.assign(pop_mean, pop_mean * decay + batch_mean * (1 - decay))train_var = tf.assign(pop_var, pop_var * decay + batch_var * (1 - decay))with tf.control_dependencies([train_mean, train_var]):return tf.nn.batch_normalization(inputs,batch_mean, batch_var, beta, scale, 0.001)else:return tf.nn.batch_normalization(inputs,pop_mean, pop_var, beta, scale, 0.001)# 模型参数
learning_rate = 1e-4   #学习率
training_iters = 3000  #训练次数
batch_size = 50        #batch的大小
display_step = 5       #每隔5步打印结果
n_classes = 2          #最终划分为两类
n_fc1 = 4096           #第一层全连接层输出的参数
n_fc2 = 2048           #第二层全连接层输出的参数# 构建模型
x = tf.placeholder(tf.float32, [None, 227, 227, 3])  #占位符
y = tf.placeholder(tf.float32, [None, n_classes])
#按照论文中的参数设置Alexnet每层网络的参数
#每层网络权重
W_conv = {'conv1': tf.Variable(tf.truncated_normal([11, 11, 3, 96], stddev=0.0001)),'conv2': tf.Variable(tf.truncated_normal([5, 5, 96, 256], stddev=0.01)),'conv3': tf.Variable(tf.truncated_normal([3, 3, 256, 384], stddev=0.01)),'conv4': tf.Variable(tf.truncated_normal([3, 3, 384, 384], stddev=0.01)),'conv5': tf.Variable(tf.truncated_normal([3, 3, 384, 256], stddev=0.01)),'fc1': tf.Variable(tf.truncated_normal([6 * 6 * 256, n_fc1], stddev=0.1)),'fc2': tf.Variable(tf.truncated_normal([n_fc1, n_fc2], stddev=0.1)),'fc3': tf.Variable(tf.truncated_normal([n_fc2, n_classes], stddev=0.1))}
#每层网络的偏置
b_conv = {'conv1': tf.Variable(tf.constant(0.0, dtype=tf.float32, shape=[96])),'conv2': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[256])),'conv3': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[384])),'conv4': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[384])),'conv5': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[256])),'fc1': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[n_fc1])),'fc2': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[n_fc2])),'fc3': tf.Variable(tf.constant(0.0, dtype=tf.float32, shape=[n_classes]))}x_image = tf.reshape(x, [-1, 227, 227, 3])   #将xreshape为张量# 卷积层 1
conv1 = tf.nn.conv2d(x_image, W_conv['conv1'], strides=[1, 4, 4, 1], padding='VALID')
conv1 = tf.nn.bias_add(conv1, b_conv['conv1'])
conv1 = batch_norm(conv1, True)
conv1 = tf.nn.relu(conv1)# 池化层 1
pool1 = tf.nn.avg_pool(conv1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')
norm1 = tf.nn.lrn(pool1, 5, bias=1.0, alpha=0.001 / 9.0, beta=0.75)# 卷积层 2
conv2 = tf.nn.conv2d(pool1, W_conv['conv2'], strides=[1, 1, 1, 1], padding='SAME')
conv2 = tf.nn.bias_add(conv2, b_conv['conv2'])
conv2 = batch_norm(conv2, True)
conv2 = tf.nn.relu(conv2)# 池化层 2
pool2 = tf.nn.avg_pool(conv2, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')# 卷积层3
conv3 = tf.nn.conv2d(pool2, W_conv['conv3'], strides=[1, 1, 1, 1], padding='SAME')
conv3 = tf.nn.bias_add(conv3, b_conv['conv3'])
conv3 = batch_norm(conv3, True)
conv3 = tf.nn.relu(conv3)# 卷积层4
conv4 = tf.nn.conv2d(conv3, W_conv['conv4'], strides=[1, 1, 1, 1], padding='SAME')
conv4 = tf.nn.bias_add(conv4, b_conv['conv4'])
conv4 = batch_norm(conv4, True)
conv4 = tf.nn.relu(conv4)# 卷积层5
conv5 = tf.nn.conv2d(conv4, W_conv['conv5'], strides=[1, 1, 1, 1], padding='SAME')
conv5 = tf.nn.bias_add(conv5, b_conv['conv5'])
conv5 = batch_norm(conv5, True)
conv5 = tf.nn.relu(conv5)# 池化层5
pool5 = tf.nn.avg_pool(conv5, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')
reshape = tf.reshape(pool5, [-1, 6 * 6 * 256])
fc1 = tf.add(tf.matmul(reshape, W_conv['fc1']), b_conv['fc1'])
fc1 = batch_norm(fc1, True, False)
fc1 = tf.nn.relu(fc1)# 全连接层 2
fc2 = tf.add(tf.matmul(fc1, W_conv['fc2']), b_conv['fc2'])
fc2 = batch_norm(fc2, True, False)
fc2 = tf.nn.relu(fc2)
out = tf.add(tf.matmul(fc2, W_conv['fc3']), b_conv['fc3'])# 定义损失
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y,logits=out))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(loss)
# 评估模型
correct_pred = tf.equal(tf.argmax(out,1),tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))init = tf.global_variables_initializer()#独热编码,可以提高准确度
def onehot(labels):'''one-hot 编码'''n_sample = len(labels)n_class = max(labels) + 1onehot_labels = np.zeros((n_sample, n_class))onehot_labels[np.arange(n_sample), labels] = 1return onehot_labelssave_model = "./model/AlexNetModel.ckpt"   #模型保存的地址以及名字def train(opech):with tf.Session() as sess:sess.run(init)train_writer = tf.summary.FileWriter(".//log", sess.graph)  # 输出日志的地方saver = tf.train.Saver()c = []start_time = time.time()coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(coord=coord)step = 0for i in range(opech):step = iimage, label = sess.run([image_batch, label_batch])labels = onehot(label)acc=[]sess.run(optimizer, feed_dict={x: image, y: labels})loss_record = sess.run(loss, feed_dict={x: image, y: labels})acc=sess.run(accuracy,feed_dict={x:image,y:labels})print("now the loss is %f " % loss_record)print("now the accuracy is %f "%acc)c.append(loss_record)end_time = time.time()print('time: ', (end_time - start_time))start_time = end_timeprint("---------------%d onpech is finished-------------------" % i)print("Optimization Finished!")#        checkpoint_path = os.path.join(".//model", 'model.ckpt')  # 输出模型的地方saver.save(sess, save_model)print("Model Save Finished!")coord.request_stop()coord.join(threads)plt.plot(c)plt.xlabel('Iter')plt.ylabel('loss')plt.title('lr=%f, ti=%d, bs=%d' % (learning_rate, training_iters, batch_size))plt.tight_layout()plt.savefig('cat_and_dog_AlexNet.jpg', dpi=200)train(training_iters)

训练时只需要更改训练集的地址即可

4、训练过程

在这里插入图片描述
训练结束后模型会保存在model文件夹中,我们就可以用训练好的模型进行测试啦。

5、模型测试

import cv2
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import time
import os
import input_data
from PIL import Image
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.InteractiveSession(config=config)testfile = 'D:\\神经网络\\Alexnet\\猫狗数据集\\test\\'#测试集地址
def batch_norm(inputs,is_train,is_conv_out=True,decay=0.999):scale=tf.Variable(tf.ones([inputs.get_shape()[-1]]))beta = tf.Variable(tf.zeros([inputs.get_shape()[-1]]))pop_mean = tf.Variable(tf.zeros([inputs.get_shape()[-1]]), trainable=False)pop_var = tf.Variable(tf.ones([inputs.get_shape()[-1]]), trainable=False)if is_train:if is_conv_out:batch_mean, batch_var = tf.nn.moments(inputs, [0, 1, 2])else:batch_mean, batch_var = tf.nn.moments(inputs, [0])train_mean = tf.assign(pop_mean, pop_mean * decay + batch_mean * (1 - decay))train_var = tf.assign(pop_var, pop_var * decay + batch_var * (1 - decay))with tf.control_dependencies([train_mean, train_var]):return tf.nn.batch_normalization(inputs,batch_mean, batch_var, beta, scale, 0.001)else:return tf.nn.batch_normalization(inputs,pop_mean, pop_var, beta, scale, 0.001)# 模型参数
learning_rate = 1e-4
training_iters = 200
batch_size = 50
display_step = 5
n_classes = 2
n_fc1 = 4096
n_fc2 = 2048# 构建模型
x = tf.placeholder(tf.float32, [None, 227, 227, 3])
y = tf.placeholder(tf.float32, [None, n_classes])W_conv = {'conv1': tf.Variable(tf.truncated_normal([11, 11, 3, 96], stddev=0.0001)),'conv2': tf.Variable(tf.truncated_normal([5, 5, 96, 256], stddev=0.01)),'conv3': tf.Variable(tf.truncated_normal([3, 3, 256, 384], stddev=0.01)),'conv4': tf.Variable(tf.truncated_normal([3, 3, 384, 384], stddev=0.01)),'conv5': tf.Variable(tf.truncated_normal([3, 3, 384, 256], stddev=0.01)),'fc1': tf.Variable(tf.truncated_normal([6 * 6 * 256, n_fc1], stddev=0.1)),'fc2': tf.Variable(tf.truncated_normal([n_fc1, n_fc2], stddev=0.1)),'fc3': tf.Variable(tf.truncated_normal([n_fc2, n_classes], stddev=0.1))}
b_conv = {'conv1': tf.Variable(tf.constant(0.0, dtype=tf.float32, shape=[96])),'conv2': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[256])),'conv3': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[384])),'conv4': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[384])),'conv5': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[256])),'fc1': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[n_fc1])),'fc2': tf.Variable(tf.constant(0.1, dtype=tf.float32, shape=[n_fc2])),'fc3': tf.Variable(tf.constant(0.0, dtype=tf.float32, shape=[n_classes]))}x_image = tf.reshape(x, [-1, 227, 227, 3])# 卷积层 1
conv1 = tf.nn.conv2d(x_image, W_conv['conv1'], strides=[1, 4, 4, 1], padding='VALID')
conv1 = tf.nn.bias_add(conv1, b_conv['conv1'])
conv1 = batch_norm(conv1, True)
conv1 = tf.nn.relu(conv1)# 池化层 1
pool1 = tf.nn.avg_pool(conv1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')
norm1 = tf.nn.lrn(pool1, 5, bias=1.0, alpha=0.001 / 9.0, beta=0.75)# 卷积层 2
conv2 = tf.nn.conv2d(pool1, W_conv['conv2'], strides=[1, 1, 1, 1], padding='SAME')
conv2 = tf.nn.bias_add(conv2, b_conv['conv2'])
conv2 = batch_norm(conv2, True)
conv2 = tf.nn.relu(conv2)# 池化层 2
pool2 = tf.nn.avg_pool(conv2, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')# 卷积层3
conv3 = tf.nn.conv2d(pool2, W_conv['conv3'], strides=[1, 1, 1, 1], padding='SAME')
conv3 = tf.nn.bias_add(conv3, b_conv['conv3'])
conv3 = batch_norm(conv3, True)
conv3 = tf.nn.relu(conv3)# 卷积层4
conv4 = tf.nn.conv2d(conv3, W_conv['conv4'], strides=[1, 1, 1, 1], padding='SAME')
conv4 = tf.nn.bias_add(conv4, b_conv['conv4'])
conv4 = batch_norm(conv4, True)
conv4 = tf.nn.relu(conv4)# 卷积层5
conv5 = tf.nn.conv2d(conv4, W_conv['conv5'], strides=[1, 1, 1, 1], padding='SAME')
conv5 = tf.nn.bias_add(conv5, b_conv['conv5'])
conv5 = batch_norm(conv5, True)
conv5 = tf.nn.relu(conv5)# 池化层5
pool5 = tf.nn.avg_pool(conv5, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID')
reshape = tf.reshape(pool5, [-1, 6 * 6 * 256])
fc1 = tf.add(tf.matmul(reshape, W_conv['fc1']), b_conv['fc1'])
fc1 = batch_norm(fc1, True, False)
fc1 = tf.nn.relu(fc1)# 全连接层 2
fc2 = tf.add(tf.matmul(fc1, W_conv['fc2']), b_conv['fc2'])
fc2 = batch_norm(fc2, True, False)
fc2 = tf.nn.relu(fc2)
out = tf.add(tf.matmul(fc2, W_conv['fc3']), b_conv['fc3'])saver = tf.train.Saver()with tf.device('/gpu:0'):def Evaluate(testfile):count = 0sums = 0start_time = time.time()with tf.Session() as sess:# sess.run(tf.initialize_all_variables())saver.restore(sess, './model/AlexNetModel.ckpt-2000')#提取模型参数for root, sub_folders, files in os.walk(testfile):for name in files:sums += 1imagefile = os.path.join(root, name)print(imagefile)image = Image.open(imagefile)image = image.resize([224, 224])image_array = np.array(image) image = tf.cast(image_array, tf.float32)image = tf.image.per_image_standardization(image)image = tf.reshape(image, [1, 224, 224, 3])image = sess.run(image)prediction = sess.run(out,feed_dict={x: image})end_time = time.time()print('time: ', (end_time - start_time))start_time = end_timemax_index = np.argmax(prediction)if max_index==0:print("猫")else:print("狗")if max_index == 0 and name.split('.')[0] == 'cat':count += 1if max_index == 1 and name.split('.')[0] == 'dog':count += 1print(" The accuracy is: ", count,sums)print(" The accuracy is: ", count / sums)print(" The accuracy is: ", count,sums)Evaluate(testfile)

三、总结

我们首先要做的就是划分数据集,先运行devide.py文件,从训练集中抽取20%作为测试集,运行结束之后,运行reshape.py文件,将训练集和测试集都reshape为224x224,然后运行train.py文件,注意要修改测试集的地址。训练完成以后模型保存在model文件夹中,我们运行evaluate.py文件进行模型测试,注意要修改模型所在的地址。
各位同学如果有不懂的地方可以评论或者私信我,我都会一一解答,有错误的地方还请大佬指正


http://chatgpt.dhexx.cn/article/xYIUeddN.shtml

相关文章

宠物狗之家

开发工具(eclipse/idea/vscode等): 数据库(sqlite/mysql/sqlserver等): 功能模块(请用文字描述,至少200字):

Rockchip开发系列 - 9.watchdog看门狗

By: fulinux E-mail: fulinux@sina.com Blog: https://blog.csdn.net/fulinus 喜欢的盆友欢迎点赞和订阅! 你的喜欢就是我写作的动力! 目录 dts中的watchdog节点watchdog驱动文件TRM watchdog:WDT框图功能描述计数器中断系统复位复位脉冲长度操作流程图寄存器描述寄存器设置…

Linux系统看门狗应用编程

目录 看门狗应用编程介绍打开设备获取设备支持哪些功能:WDIOC_GETSUPPORT获取/设置超时时间:WDIOC_GETTIMEOUT、WDIOC_SETTIMEOUT开启/关闭看门狗:WDIOC_SETOPTIONS喂狗:WDIOC_KEEPALIVE 看门狗应用编程实战 在产品化的嵌入式系统…

宠物狗之家网站

开发工具(eclipse/idea/vscode等): 数据库(sqlite/mysql/sqlserver等): 功能模块(请用文字描述,至少200字):

java泛型波浪号_DogBrown

对于 Vue.nextTick 方法,自己有些疑惑。在查询了各种资料后,总结了一下其原理和用途,如有错误,请不吝赐教。 概览官方文档说明:用法: 在下次 DOM 更新循环结束之后执行延迟回调。在修改数据之后立即使用这个…

Linux Watchdog看门狗理解

目录 介绍 简单Watchdog Linux Watchdog daemon Watchdog设备驱动配置 测试Watchdog设备的复位功能 介绍 Watchdog timer(看门狗定时器)是一种电子计时器,其用于检测和恢复计算机故障。在正常操作期间,计算机定期重置看门狗定…

噪音监测传感系统

远程噪声监测系统是一种新型的环境监测系统,可以实现环境噪声、温度、粉尘、风向等参数的在线自动监测。它利用传感技术、通信技术和计算机及其网络技术将环境状态有机地结合起来,形成一起来。  原理  首先,远程噪声监测现场噪声测量控制…

Matlab——噪声的检测和处理实验

本次实验首先由matlab中的randn()函数模拟噪声信号,模拟确定性信号s(t)的抽样信号,并根据有无信号到达的概率,计算两者出现的频数,在matlab软件中仿真出有信号到达和无信号到达的两种接受信号。在此基础上,根据似然比和…

【去噪】A Physics-Based Noise Formation Model for Extreme Low-Light Raw Denoising噪声建模详解

文章目录 0. 前言1. 主要贡献1.1 建立了一个全面的噪声模型,可以准确地描述低光环境下的真实噪声结构1.2 提出了一种噪声参数标定方法1.2.1 估计系统总体增益 K K K1.2.2 估计颜色偏差噪声的 μ c \mu_c μc​1.2.3 估计行噪声的σr1.2.4 估计读出噪声中的λ、σT …

【Android工具】用手机测量噪声的工具软件,噪声仪分贝计,量化噪声声音工具...

今天分享一个通过手机麦克风测量环境噪声的工具——声级计(噪声仪)。 本来是要分享另一款的,但下载下来的是xapk的安装包,太麻烦了,功能差不多,大家就先用这款吧,有条件的朋友可以去play自己下载…

噪声系数评估的简易方法

1. 概要 有三种常用的噪声系数的测量方法[1],分别是: 噪声系数测试仪法增益法Y系数法 这些测量方法都需要利用复杂的测试仪器,有没有更简单的方法呢?本文介绍一个简单的仅需要RF信号发生器以及一个能采集数据的设备(比…

图像传感器噪声建模与分析

图像传感器在做信号采集的时候往往会引入噪声,在采集到的raw图像中能够拿到没有经过任何处理的传感器信号,因此对于传感器噪声进行分析与建模有助于我们认识传感器噪声,从而帮助我们设计raw图像的降噪算法。本文从传感器模型层面分析单像素点…

气象插值软件anusplin的使用

气象插值软件anusplin的使用 1、简介 ANUSPLIN软件包提供了一种使用薄板平滑样条对噪声多变量数据进行透明分析和插值的工具。该软件包通过提供全面的统计分析、数据诊断和空间分布的标准误差来支持这一过程。通常运用到降水、气温等气象要素的插值当中,可以引入高…

【模拟CMOS集成电路】电路噪声—— 噪声分析基础(1)

电路噪声——噪声分析基础(1) 前言1噪声的定义2噪声的描述2.1统计特性(1)平均功率(2)功率谱密度(PSD) 2.2噪声相关指标(1)SNR(2)SNDR …

IPEmotion的NVH噪声测试模块——坎贝尔图

德国IPETRONIK的IPEmotion软件除了可以对之前介绍的热管理试验及热管理台架试验、电性能试验和道路试验等各种进行基本的温度、模拟量和数字信号的采集分析外,无论专业版、开发版还是分析版均支持噪声分析模块。该模块支持噪声数据离线后处理,包括Campbe…

ADC噪声全面分析 -02- ADC 噪声测量方法和相关参数

ADC 噪声测量方法和参数 在解释如何测量 ADC 噪声之前,重要的是要了解,当您查看 ADC 数据表规格时,相关指标参数表征对象是 ADC,而不是设计的电子系统。因此,ADC 制造商测试 ADC 噪声的方式和测试系统本身应该展示 AD…

频谱分析仪测量噪声系数方法介绍

用频谱仪测量噪声系数:测量框图为:基于噪声系数的定义得到的一个测量公式为:NFPNOUT-(-174dBm/Hz20lg(BW)Gain)(1)公式中,PNOUT是已测的总共输出噪声功率,-174dBm/Hz是290oK(室温)时环境噪声的功…

频谱分析仪怎么测相位噪声?

相位噪声是评估和分析信号质量的一个重要参数,尤其在无线通信、雷达信号处理等领域中具有重要的意义。罗德(Rohde & Schwarz)频谱分析仪是一款常见的仪器,可以用于测量和分析信号的相位噪声。本文将详细介绍罗德频谱分析仪相位…

声学仿真分析工具Acoustics 在Workbench中这样学

声学仿真分析工具Acoustics 在Workbench中这样学 付亚兰 讲师 2年前 浏览11376 关注 声学有限元仿真 主要用于模拟声压波在声介质中的生成、传播、辐射、吸收和反射。随着有限元软件的发展和人们对噪声问题的重视,声学有限元仿真在越来越多的行业得到广泛应用。 比…

Sysnoise5.6安装教程和软件下载

Sysnoise5.6安装教程和软件下载 【尊重 原创,转载请注明出处 】http://blog.csdn.net/guyuealian/article/details/51187240 Sysnoise是目前市场上最先进的声-振分析软件,用户可以利用Sysnoise软件仿真计算机有关设备噪声的各种数据,并能帮助…