当前位置: 首页 > news >正文

PyTorch DataLoader 报错 “DataLoader worker exited unexpectedly“ 的解决方案

注意:博主没有重写d2l的源代码文件,而是创建了一个新的python文件,并重写了该方法。

一、代码运行日志

C:\Users\Administrator\anaconda3\envs\limu\python.exe G:/PyCharmProjects/limu-d2l/ch03/softmax_regression.py
Traceback (most recent call last):File "<string>", line 1, in <module>
Traceback (most recent call last):File "<string>", line 1, in <module>File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 116, in spawn_mainFile "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 116, in spawn_mainexitcode = _main(fd, parent_sentinel)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 125, in _mainTraceback (most recent call last):
exitcode = _main(fd, parent_sentinel)File "<string>", line 1, in <module>File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 125, in _main
Traceback (most recent call last):File "<string>", line 1, in <module>
prepare(preparation_data)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 236, in prepareprepare(preparation_data)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 236, in prepare_fixup_main_from_path(data['init_main_from_path'])File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path_fixup_main_from_path(data['init_main_from_path'])File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_pathmain_content = runpy.run_path(main_path,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 265, in run_pathmain_content = runpy.run_path(main_path,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 265, in run_pathreturn _run_module_code(code, init_globals, run_name,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 97, in _run_module_codereturn _run_module_code(code, init_globals, run_name,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 97, in _run_module_code_run_code(code, mod_globals, init_globals,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 87, in _run_code_run_code(code, mod_globals, init_globals,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 87, in _run_codeFile "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 116, in spawn_mainFile "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 116, in spawn_mainexec(code, run_globals)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 97, in <module>
exec(code, run_globals)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 97, in <module>train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 81, in train_ch03
exitcode = _main(fd, parent_sentinel)
train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 125, in _mainFile "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 81, in train_ch03exitcode = _main(fd, parent_sentinel)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 125, in _maintrain_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)train_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 64, in train_epoch_ch03File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 64, in train_epoch_ch03prepare(preparation_data)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 236, in prepareprepare(preparation_data)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 236, in preparefor X, y in train_iter:for X, y in train_iter:File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 441, in __iter__File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 441, in __iter___fixup_main_from_path(data['init_main_from_path'])_fixup_main_from_path(data['init_main_from_path'])File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_pathFile "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_pathmain_content = runpy.run_path(main_path,main_content = runpy.run_path(main_path,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 265, in run_pathFile "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 265, in run_pathreturn self._get_iterator()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 388, in _get_iteratorreturn self._get_iterator()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 388, in _get_iteratorreturn _run_module_code(code, init_globals, run_name,return _run_module_code(code, init_globals, run_name,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 97, in _run_module_codeFile "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 97, in _run_module_codereturn _MultiProcessingDataLoaderIter(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1042, in __init__return _MultiProcessingDataLoaderIter(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1042, in __init___run_code(code, mod_globals, init_globals,    
_run_code(code, mod_globals, init_globals,File "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 87, in _run_codeFile "C:\Users\Administrator\anaconda3\envs\limu\lib\runpy.py", line 87, in _run_codeexec(code, run_globals)    
exec(code, run_globals)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 97, in <module>File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 97, in <module>train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 81, in train_ch03
train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 81, in train_ch03w.start()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\process.py", line 121, in startw.start()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\process.py", line 121, in starttrain_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)train_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 64, in train_epoch_ch03File "G:\PyCharmProjects\limu-d2l\ch03\softmax_regression.py", line 64, in train_epoch_ch03self._popen = self._Popen(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 224, in _Popenfor X, y in train_iter:for X, y in train_iter:File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 441, in __iter__File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 441, in __iter__self._popen = self._Popen(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 224, in _Popenreturn _default_context.get_context().Process._Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 327, in _Popenreturn _default_context.get_context().Process._Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 327, in _Popenreturn self._get_iterator()return self._get_iterator()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 388, in _get_iteratorFile "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 388, in _get_iteratorreturn Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__return Popen(process_obj)            return _MultiProcessingDataLoaderIter(self)return _MultiProcessingDataLoaderIter(self)prep_data = spawn.get_preparation_data(process_obj._name)File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1042, in __init__File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1042, in __init__File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 154, in get_preparation_dataFile "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__prep_data = spawn.get_preparation_data(process_obj._name)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main_check_not_importing_main()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_mainraise RuntimeError('''
RuntimeError: An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.w.start()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\process.py", line 121, in startw.start()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\process.py", line 121, in startraise RuntimeError('''
RuntimeError: An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.self._popen = self._Popen(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 224, in _Popenself._popen = self._Popen(self)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 224, in _Popenreturn _default_context.get_context().Process._Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 327, in _Popen
return _default_context.get_context().Process._Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\context.py", line 327, in _Popenreturn Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__return Popen(process_obj)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__prep_data = spawn.get_preparation_data(process_obj._name)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 154, in get_preparation_dataprep_data = spawn.get_preparation_data(process_obj._name)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 154, in get_preparation_data_check_not_importing_main()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main_check_not_importing_main()File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_mainraise RuntimeError('''raise RuntimeError('''
RuntimeError: RuntimeErrorAn attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.: An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.
Traceback (most recent call last):File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1132, in _try_get_datadata = self._data_queue.get(timeout=timeout)File "C:\Users\Administrator\anaconda3\envs\limu\lib\multiprocessing\queues.py", line 108, in getraise Empty
_queue.EmptyThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "G:/PyCharmProjects/limu-d2l/ch03/softmax_regression.py", line 97, in <module>train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)File "G:/PyCharmProjects/limu-d2l/ch03/softmax_regression.py", line 81, in train_ch03train_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)File "G:/PyCharmProjects/limu-d2l/ch03/softmax_regression.py", line 64, in train_epoch_ch03for X, y in train_iter:File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 633, in __next__data = self._next_data()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1328, in _next_dataidx, data = self._get_data()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1294, in _get_datasuccess, data = self._try_get_data()File "C:\Users\Administrator\anaconda3\envs\limu\lib\site-packages\torch\utils\data\dataloader.py", line 1145, in _try_get_dataraise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
RuntimeError: DataLoader worker (pid(s) 14032, 23312, 21048, 1952) exited unexpectedlyProcess finished with exit code 1

二、问题分析

这个错误是由于在使用多进程 DataLoader 时出现的问题,通常与 Windows 操作系统相关。在 Windows 上,使用多进程的 DataLoader 可能会导致一些问题,这与 Windows 的进程模型不太兼容。

三、解决方案(使用单进程 DataLoader)

在 Windows 上,将 DataLoader 的 num_workers 参数设置为 0,以使用单进程 DataLoader。这会禁用多进程加载数据,虽然可能会导致数据加载速度变慢,但通常可以解决与多进程 DataLoader 相关的问题。

d2l.load_data_fashion_mnist(batch_size)源代码

def get_dataloader_workers():"""Use 4 processes to read the data.Defined in :numref:`sec_utils`"""return 4def load_data_fashion_mnist(batch_size, resize=None):"""Download the Fashion-MNIST dataset and then load it into memory.Defined in :numref:`sec_utils`"""trans = [transforms.ToTensor()]if resize:trans.insert(0, transforms.Resize(resize))trans = transforms.Compose(trans)mnist_train = torchvision.datasets.FashionMNIST(root="../data", train=True, transform=trans, download=True)mnist_test = torchvision.datasets.FashionMNIST(root="../data", train=False, transform=trans, download=True)return (torch.utils.data.DataLoader(mnist_train, batch_size, shuffle=True,num_workers=get_dataloader_workers()),torch.utils.data.DataLoader(mnist_test, batch_size, shuffle=False,num_workers=get_dataloader_workers()))

在代码中使用修改后的load_data_fashion_mnist函数

def load_data_fashion_mnist(batch_size, resize=None, num_workers=4):"""下载Fashion-MNIST数据集,然后将其加载到内存中"""trans = [transforms.ToTensor()]if resize:trans.index(0, transforms.Resize(resize))trans = transforms.Compose(trans)mnist_train = torchvision.datasets.FashionMNIST(root='../data', train=True, transform=trans, download=True)mnist_test = torchvision.datasets.FashionMNIST(root='../data', train=False, transform=trans, download=True)return (data.DataLoader(mnist_train, batch_size, shuffle=True, num_workers=num_workers),data.DataLoader(mnist_test, batch_size, shuffle=False, num_workers=num_workers))
train_iter, test_iter = fashion_mnist.load_data_fashion_mnist(batch_size, num_workers=0)

在这里插入图片描述

四、为什么将 DataLoader 的 num_workers 参数设置为 0,是使用的单进程,而不是零进程呢?

在 PyTorch 的 DataLoader 中,num_workers 参数控制了用于加载数据的子进程数量。当 num_workers 被设置为 0 时,实际上是表示不使用任何子进程来加载数据,即单进程加载数据。

为什么不是零进程?这是因为 DataLoader 需要至少一个进程来加载数据,这个进程被称为主进程。主进程负责数据加载和分发给训练的进程。当 num_workers 设置为 0 时,只有主进程用于加载和处理数据,没有额外的子进程。这是一种单进程的数据加载方式。

如果将 num_workers 设置为 1,则会有一个额外的子进程来加载数据,总共会有两个进程:一个主进程和一个数据加载子进程。这种设置可以在某些情况下提高数据加载的效率,特别是当数据加载耗时较长时,子进程可以并行地加载数据,从而加速训练过程。

五、完整训练代码

import torch
from d2l import torch as d2l
import fashion_mnistbatch_size = 256
train_iter, test_iter = fashion_mnist.load_data_fashion_mnist(batch_size, num_workers=0)# 初始化模型参数
num_inputs = 784  # 每个输入图像的通道数为1, 高度和宽度均为28像素
num_outputs = 10W = torch.normal(0, 0.01, size=(num_inputs, num_outputs), requires_grad=True)
b = torch.zeros(num_outputs, requires_grad=True)# 定义softmax操作
def softmax(X):"""矩阵中的非常大或非常小的元素可能造成数值上溢或者下溢解决方案: P84 3.7.2 重新审视softmax的实现"""X_exp = torch.exp(X)partition = X_exp.sum(1, keepdim=True)return X_exp / partition# 定义模型
def net(X):return softmax(torch.matmul(X.reshape((-1, W.shape[0])), W) + b)# 定义损失函数
def cross_entropy(y_hat, y):return - torch.log(y_hat[range(len(y_hat)), y])# 分类精度
def accuracy(y_hat, y):"""计算预测正确的数量"""if len(y_hat.shape) > 1 and y_hat.shape[1] > 1:y_hat = y_hat.argmax(axis=1)cmp = y_hat.type(y.dtype) == yreturn float(cmp.type(y.dtype).sum())def evaluate_accuracy(net, data_iter):"""计算在制定数据集上模型的精度"""if isinstance(net, torch.nn.Module):net.eval()metric = d2l.Accumulator(2)with torch.no_grad():for X, y in data_iter:metric.add(accuracy(net(X), y), y.numel())return metric[0] / metric[1]# 训练
def train_epoch_ch03(net, train_iter, loss, updater):if isinstance(net, torch.nn.Module):net.train()# 训练损失总和, 训练准确度总和, 样本数metric = d2l.Accumulator(3)for X, y in train_iter:y_hat = net(X)l = loss(y_hat, y)if isinstance(updater, torch.optim.Optimizer):updater.zero_grad()l.mean().backward()updater.step()else:l.sum().backward()updater(X.shape[0])metric.add(float(l.sum()), accuracy(y_hat, y), y.numel())# 返回训练损失和训练精度return metric[0] / metric[2], metric[1] / metric[2]def train_ch03(net, train_iter, test_iter, loss, num_epochs, updater):for epoch in range(num_epochs):train_loss, train_acc = train_epoch_ch03(net, train_iter, loss, updater)test_acc = evaluate_accuracy(net, test_iter)print(f'epoch {epoch + 1}, train_loss {train_loss:f}, train_acc {train_acc:f}, test_acc {test_acc:f}')assert train_loss < 0.5, train_lossassert train_acc <= 1 and train_acc > 0.7, train_accassert test_acc <= 1 and test_acc > 0.7, test_acclr = 0.1def updater(batch_size):return d2l.sgd([W, b], lr, batch_size)num_epochs = 10
train_ch03(net, train_iter, test_iter, cross_entropy, num_epochs, updater)

相关文章:

PyTorch DataLoader 报错 “DataLoader worker exited unexpectedly“ 的解决方案

注意&#xff1a;博主没有重写d2l的源代码文件&#xff0c;而是创建了一个新的python文件&#xff0c;并重写了该方法。 一、代码运行日志 C:\Users\Administrator\anaconda3\envs\limu\python.exe G:/PyCharmProjects/limu-d2l/ch03/softmax_regression.py Traceback (most r…...

【AI绘画--七夕篇】:七夕特别教程,使用SDXL绘制你的心上人(Stable Diffusion)(封神榜—妲己)

目录 前言0、介绍0-0、结果展示0-1、Stable Diffusion0-2、sdxl介绍 一、云端部署Stable Diffusion1-1、云端平台的优势 二、平台介绍三、注册账号并且开始炼制3-1、购买算力并创建工作空间3-2、启动工作空间3-3、应用市场一键安装3-4、使用Stable-Diffusion作图 四、有女朋友的…...

hadoop2的集群数据将副本存储在hadoop3

在 Hadoop 集群中&#xff0c;HDFS 副本是分布式存储的&#xff0c;会存储在不同的节点上。因此&#xff0c;如果您的 HDFS 所在路径是在 Hadoop2 集群中&#xff0c;您可以在 Hadoop3 集群上添加新的节点&#xff0c;并向 Hadoop3 集群中添加这些新节点上的数据副本。 以下是…...

c# ??=

空合并运算符 ??&#xff0c;用于定义引用类型和可空类型的默认值。如果此运算符的左操作符不为Null&#xff0c;则此操作符返回左操作数&#xff0c;否则返回右操作数。 例如&#xff1a; //当a不为空时返回a&#xff0c;为null时返回b var c a ?? b;空合并赋值运算符??…...

存储系统性能优化中IOMMU的作用是什么?

一、IOMMU原理 IOMMU(Input/Output Memory Management Unit)是一种用于管理计算机内存的技术,它允许将物理内存映射到虚拟地址空间。IOMMU通过使用专用的硬件来管理和优化内存访问,从而提高系统性能和稳定性。本文将详细介绍IOMMU的原理,并介绍一些应用案例和典型的问题解…...

localhost:8080 is already in use

报错原因&#xff1a;本机的8080端口号已经被占用。因为机器的空闲端口号是随机分配的&#xff0c;而idea默认启动的端口号是8080,所以是存在这种情况。 对于这个问题&#xff0c;我们只需要重启idea或者修改项目的启动端口号即可。 更推荐第二种。对于修改项目启动端口号&…...

机器学习深度学习——NLP实战(自然语言推断——数据集)

&#x1f468;‍&#x1f393;作者简介&#xff1a;一位即将上大四&#xff0c;正专攻机器学习的保研er &#x1f30c;上期文章&#xff1a;机器学习&&深度学习——NLP实战&#xff08;情感分析模型——textCNN实现&#xff09; &#x1f4da;订阅专栏&#xff1a;机器…...

攻防世界-simple_php

原题 解题思路 flag被分成了两个部分&#xff1a;flag2&#xff0c;flag2。获得flag1需要满足变量a0且变量a≠0&#xff0c;这看起来不能实现&#xff0c;但实际上当变量a的值是字符时&#xff0c;与数字比较会发生强制类型转换&#xff0c;所以a为字符型数据即可&#xff0c;变…...

2023MyBatis 八股文——面试题

MyBatis简介 1. MyBatis是什么&#xff1f; MyBatis 是一款优秀的持久层框架&#xff0c;一个半 ORM&#xff08;对象关系映射&#xff09;框架&#xff0c;它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及 获取结果集。MyBa…...

解决出海痛点:亚马逊云科技助力智能涂鸦,实现设备互联互通

今年6月&#xff0c;《财富》&#xff08;中文版&#xff09;发布“2023年值得关注的中国出海主力”盘点&#xff0c;在七个赛道中聚焦不断开拓新领域、影响力与日俱增的出海企业。涂鸦智能顺利入选&#xff0c;作为一家全球化公司&#xff0c;相比于产品直接到海外销售的传统出…...

国际刑警组织逮捕 14 名涉嫌盗窃 4000 万美元的网络罪犯

Bleeping Computer 网站披露&#xff0c;4 月份&#xff0c;国际刑警组织发动了一起为期四个月&#xff0c;横跨 25 个非洲国家的执法行动 “Africa Cyber Surge II”&#xff0c;共逮捕 14 名网络犯罪嫌疑人&#xff0c;摧毁 20000 多个从事勒索、网络钓鱼、BEC 和在线诈骗的犯…...

MySQL卸载-Linux版

MySQL卸载-Linux版 停止MySQL服务 systemctl stop mysqld 查询MySQL的安装文件 rpm -qa | grep -i mysql 卸载上述查询出来的所有的MySQL安装包 rpm -e mysql-community-client-plugins-8.0.26-1.el7.x86_64 --nodeps ​ rpm -e mysql-community-server-8.0.26-1.el7.x86_64 -…...

快速学会创建uni-app项目并了解pages.json文件

(创作不易&#xff0c;感谢有你&#xff0c;你的支持&#xff0c;就是我前行的最大动力&#xff0c;如果看完对你有帮助&#xff0c;请留下您的足迹&#xff09; 目录 前言 创建 uni-app 项目 通过 HBuilderX 创建 pages.json pages style globalStyle tabBar 前言…...

选云服务器还是物理服务器

选云服务器还是物理服务器 一、为什么需要云服务器或独立服务器取代共享主机 在最早之前&#xff0c;大多数的网站都是共享主机开始的&#xff0c;这里也包含了云虚拟机。这一类的站点还有其他站点都会共同托管在同一台服务器上。但是这种共享机只适用于小的网站&#xff0c;如…...

最新ChatGPT网站AI系统源码+详细图文搭建教程/支持GPT4.0/AI绘画/H5端/Prompt知识库/

一、前言 SparkAi系统是基于国外很火的ChatGPT进行开发的Ai智能问答系统。本期针对源码系统整体测试下来非常完美&#xff0c;可以说SparkAi是目前国内一款的ChatGPT对接OpenAI软件系统。 那么如何搭建部署AI创作ChatGPT&#xff1f;小编这里写一个详细图文教程吧&#xff01…...

Web3 游戏七月洞察:迈向主流采用的临界点?

作者: lesleyfootprint.network 2023 年 7 月&#xff0c;Web3 游戏领域出现了小幅增长&#xff0c;但对于许多项目来说&#xff0c;用户采用仍然是一个持续的挑战。根据 Footprint Analytics 的数据&#xff0c;活跃的区块链游戏数量略有增加&#xff0c;达到 2,471 个。然而…...

Python爬虫——scrapy_多网页下载

在DangSpider类中设置一个基础url base_url http://category.dangdang.com/pg page 1在parse方法中 # 每一页的爬取逻辑都是一样的&#xff0c;所以只需要执行每一页的请求再次调用parse方法就可以了if self.page < 100:self.page 1url self.base_url str(self.page)…...

JDK JRE JVM 三者之间的详解

JDK : Java Development Kit JRE: Java Runtime Environment JVM : JAVA Virtual Machine JDK : Java Development Kit JDK : Java Development Kit【 Java开发者工具】&#xff0c;可以从上图可以看出&#xff0c;JDK包含JRE&#xff1b;java自己的一些开发工具中&#…...

excel常见的数学函数篇2

一、数学函数 1、ABS(number)&#xff1a;返回数字的绝对值 语法&#xff1a;ABS(数字)&#xff1b;返回数字的绝对值&#xff1b;若引用单元格&#xff0c;把数字换为单元格地址即可 2、INT(number)&#xff1a;向小取整 语法&#xff1a;INT(数字)&#xff1b;若引用单元格…...

Certify The Web (IIS)

一、简介 Certify The Web 适用于 Windows的SSL 证书管理器用户界面&#xff0c;与所有 ACME v2 CA 兼容&#xff0c;为您的 IIS/Windows 服务器轻松地安装和自动更新来自 Letencrypt.org 和其他 ACME 证书授权机构的免费 SSL/TLS 证书&#xff0c;设置 https 从未如此简单。 …...

【c语言】五子棋(EasyX图形库+背景音乐)

大家好&#xff0c;有没有觉得写了好多c语言代码&#xff0c;面对的都是黑框框控制台&#xff0c;当我们学习了基础的c语言知识&#xff0c;和EasyX图形库后&#xff0c;终于可以和黑框框saygoodbye,今天要分享给大家的是小游戏五子棋&#xff0c;跟着小张一起学习吧 EasyX图形…...

【OpenCV 】对极几何标定质量验证

标定质量验证&#xff1a; 寻找一对对应点&#xff0c;已经知道对应关系及其详细坐标&#xff0c;根据对极几何推导实现 ///get the camera intrinsics and T_Ci_Bstd::vector<Eigen::Matrix3d> M_K;std::vector<Eigen::Matrix4d> T_Ci_B;for (int i 0; i < ne…...

Netty:ByteBuf的清空操作

说明 io.netty.buffer.ByteBuf有个函数clear()&#xff0c;它可以将ByteBuf的readerIndex和writerIndex都设置为0。 代码示例 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Demo {public static void main(String[] args…...

SpringCloud最新最全面试题

目录 一、简单说一说什么是微服务&#xff1f; 二、微服务有哪些优缺点&#xff1f; 三、微服务、分布式、集群的区别&#xff1f; 四、什么是Eureka&#xff1f; 五、Eureka有那两大组件&#xff1f; 六、actuator是什么&#xff1f; 七、Discovery是什么&#xff1f; …...

leetcode359周赛

2828. 判别首字母缩略词 核心思想:枚举。只需要枚举首字母和s是否一一对应即可。 2829. k-avoiding 数组的最小总和 核心思想&#xff1a;自己的方法就是哈希表&#xff0c;枚举i的时候&#xff0c;将k-i统计起来&#xff0c;如果出现了那么就跳过。灵神的方法是数学法&#…...

nginx代理webSocket链接响应403

一、场景 使用nginx代理webSocket链接&#xff0c;nginx响应403 1、nginx访问日志响应403 [18/Aug/2023:09:56:36 0800] "GET /FS_WEB_ASS/webim_api/socket/message HTTP/1.1" 403 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit…...

websocker无法注入依赖

在公司中准备用websocker统计在线人数&#xff0c;在WebSocketServer使用StringRedisTemplate保存数据到redis中去&#xff0c;但是在保存的时候显示 StringRedisTemplate变量为null 详细问题 2023-08-20 10:37:14.109 ERROR 28240 --- [nio-7125-exec-1] o.a.t.websocket.po…...

如何进行无线网络渗透测试?

我们将重点介绍如何使用Kali Linux进行无线网络渗透测试。无线网络渗透测试是评估无线网络安全性的重要步骤&#xff0c;而Kali Linux作为一款专业的渗透测试发行版&#xff0c;提供了丰富的工具来进行这项任务。 1. 准备工作 在开始无线网络渗透测试之前&#xff0c;有一些准…...

【Python机器学习】实验15 将Lenet5应用于Cifar10数据集(PyTorch实现)

文章目录 CIFAR10数据集介绍1. 数据的下载2.修改模型与前面的参数设置保持一致3. 新建模型4. 从数据集中分批量读取数据5. 定义损失函数6. 定义优化器7. 开始训练8.测试模型 9. 手写体图片的可视化10. 多幅图片的可视化 思考题11. 读取测试集的图片预测值&#xff08;神经网络的…...

Jeep车型数据源:提供Jeep品牌车系、车型、价格、配置等信息

​​​​​ Jeep是一个极具特色的汽车品牌&#xff0c;它的所有车型都注重实用性&#xff0c;具有越野性能和高性能。Jeep品牌在汽车行业中的口碑一直是非常不错的。如果你想要了解Jeep品牌车系、车型、价格、配置等信息&#xff0c;就可以通过挖数据平台Jeep车型数据源API接口…...

clickhouse-备份恢复

一、简介 备份恢复是数据库常用的手段&#xff0c;可能大多数公司很少会对大数据所使用的数据进行备份&#xff0c;这里还是了解下比较好&#xff0c;下面做了一些简单的介绍&#xff0c;详细情况可以通过官网来查看&#xff0c;经过测试发现Disk中增量备份并不好用&#xff0…...

(2018,ProGAN)渐进式发展 GAN 以提高质量、稳定性和变化

Progressive Growing of GANs for Improved Quality, Stability, and Variation 公众号&#xff1a;EDPJ 目录 0. 摘要 1. 简介 2. GAN 的渐进式发展 3. 使用小批量标准差增加变化 4. 生成器和判别器的归一化 4.1 均衡学习率 4.2 生成器中的像素特征向量归一化 5. 评…...

负载均衡下的 WebShell 连接

目录 负载均衡简介负载均衡的分类网络通信分类 负载均衡下的 WebShell 连接场景描述难点介绍解决方法**Plan A** **关掉其中一台机器**&#xff08;作死&#xff09;**Plan B** **执行前先判断要不要执行****Plan C** 在Web 层做一次 HTTP 流量转发 &#xff08;重点&#xff0…...

Postman的高级用法—Runner的使用​

1.首先在postman新建要批量运行的接口文件夹&#xff0c;新建一个接口&#xff0c;并设置好全局变量。 2.然后在Test里面设置好要断言的方法 如&#xff1a; tests["Status code is 200"] responseCode.code 200; tests["Response time is less than 10000…...

spring如何进行依赖注入,通过set方法把Dao注入到serves

1、选择Generate右键鼠标 你在service层后面方法的这些: 2、UserService配置文件的写法是怎样的&#xff1a; 3、我们在UserController中执行一下具体写法&#xff1a; 最后我们执行一下 &#xff1a; 4、这里可能出现空指针&#xff0c;因为你当前web层,因为你new这个对象根…...

Python使用图像处理库PIL(Python Imaging Library)和NumPy库来比较两副图像的相似度

目录 1、解释说明&#xff1a; 2、使用示例&#xff1a; 3、注意事项&#xff1a; 1、解释说明&#xff1a; 在Python中&#xff0c;我们可以使用图像处理库PIL&#xff08;Python Imaging Library&#xff09;和NumPy库来比较两副图像的相似度。常用的图像相似度计算方法有…...

clickhouse扩缩容

一、背景 我们之前已经学会了搭建clickhouse集群&#xff0c;我们搭建的是一套单分片两副本的集群&#xff0c;接下来我们来测试下clickhouse的扩缩容情况 二、扩容 扩容相对来说比较简单&#xff0c;我们原来的架构如下 hostshardreplica192.169.1.111192.169.1.212 现在…...

动漫3D虚拟人物制作为企业数字化转型提供强大动力

一个 3D 虚拟数字人角色的制作流程&#xff0c;可以分为概念设定-3D 建模-贴图-蒙皮-动画-引擎测试六个步骤&#xff0c;涉及到的岗位有原画师、模型师、动画师等。角色概念设定、贴图绘制一般是由视觉设计师来完成;而建模、装配(骨骼绑定)、渲染动画是由三维设计师来制作完成。…...

数据同步工具比较:选择适合您业务需求的解决方案

在当今数字化时代&#xff0c;数据已经成为企业的核心资产。然而&#xff0c;随着业务的扩展和设备的增多&#xff0c;如何实现数据的高效管理和同步成为了一个亟待解决的问题。本文将介绍几种常见的数据同步工具&#xff0c;并对比它们的功能、性能和适用场景&#xff0c;帮助…...

Python中数据结构列表详解

列表是最常用的 Python 数据类型&#xff0c;它用一个方括号内的逗号分隔值出现&#xff0c;列表的数据项不需要具有相同的类型。 列表中的每个值都有对应的位置值&#xff0c;称之为索引&#xff0c;第一个索引是 0&#xff0c;第二个索引是 1&#xff0c;依此类推。列表都可…...

引领行业高质量发展|云畅科技参编《低代码开发平台创新发展路线图(2023)》

8月8日-9日&#xff0c;中国电子技术标准化研究院于北京顺利召开《低代码开发平台创新发展路线图&#xff08;2023&#xff09;》封闭编制会。云畅科技、浪潮、百度、广域铭岛等来自低代码开发平台解决方案供应商、用户方、科研院所等近30家相关单位的40余位专家参与了现场编制…...

Ubuntu22.04编译Nginx源码

执行如下命令 # ./configure --sbin-path/usr/local/nginx/nginx --conf-path/usr/local/nginx/nginx.conf --pid-path/usr/local/nginx/nginx.pid输出结果&#xff0c;出现如下&#xff1a; Configuration summary using system PCRE2 library OpenSSL library is not used …...

视频上传,限制时长,获取视频时长

使用element的upload上传文件时&#xff0c;除了类型和大小&#xff0c;需求需要限制只能长传18秒内的视频&#xff0c;这里通过upload的before-upload&#xff0c;以及创建一个音频元素对象拿到durtaion时长属性来实现。 getVideoTime(file) {return new Promise(async (resol…...

Open3D 进阶(5)变分贝叶斯高斯混合点云聚类

目录 一、算法原理二、代码实现三、结果展示四、测试数据本文由CSDN点云侠原创,原文链接。如果你不是在点云侠的博客中看到该文章,那么此处便是不要脸的爬虫。 系列文章(连载中。。。爬虫,你倒是爬个完整的呀?): Open3D 进阶(1) MeanShift点云聚类Open3D 进阶(2)DB…...

5、css学习5(链接、列表)

1、css可以设置链接的四种状态样式。 a:link - 正常&#xff0c;未访问过的链接a:visited - 用户已访问过的链接a:hover - 当用户鼠标放在链接上时a:active - 链接被点击的那一刻 2、 a:hover 必须在 a:link 和 a:visited 之后&#xff0c; a:active 必须在 a:hover 之后&…...

Synchronized与Java线程的关系

前言 ​ Java多线程处理任务时&#xff0c;为了线程安全&#xff0c;通常会对共享资源进行加锁&#xff0c;拿到锁的线程才能进行访问共享资源。而加锁方式通过都是Synchronized锁或者Lock锁。 ​ 那么多线程在协同工作的时候&#xff0c;线程状态的变化都与锁对象有关系。 …...

使用本地电脑搭建可以远程访问的SFTP服务器

文章目录 1. 搭建SFTP服务器1.1 下载 freesshd 服务器软件1.3 启动SFTP服务1.4 添加用户1.5 保存所有配置 2. 安装SFTP客户端FileZilla测试2.1 配置一个本地SFTP站点2.2 内网连接测试成功 3. 使用cpolar内网穿透3.1 创建SFTP隧道3.2 查看在线隧道列表 4. 使用SFTP客户端&#x…...

批量修改文件名怎么操作?

批量修改文件名怎么操作&#xff1f;不管你使用电脑处理工作还是进行学习&#xff0c;都会在电脑中产生很多的文件&#xff0c;时间一久电脑里的文件更加杂乱无章&#xff0c;这时候如果不对电脑中的文件进行及时的管理&#xff0c;那么很可能出现文件丢失而你自己还发现不了的…...

【LeetCode】538.把二叉搜索树转换为累加树

题目 给出二叉 搜索 树的根节点&#xff0c;该树的节点值各不相同&#xff0c;请你将其转换为累加树&#xff08;Greater Sum Tree&#xff09;&#xff0c;使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 提醒一下&#xff0c;二叉搜索树满足下列约束条件…...

linux 安装 kibana

首先下载 kibana https://www.elastic.co/cn/downloads/kibana 然后上传到linux /usr/local 目录下解压安装 修改config/kibana.yml 配置文件&#xff0c;将elasticsearch.hosts 然后再nginx 中做一个端口映射&#xff0c;实现在浏览器中输入后xxxx:5602 nginx 可以将请求转发…...