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

Day 66-68 主动学习之ALEC

代码:

package dl;import java.io.FileReader;
import java.util.*;
import weka.core.Instances;/*** Active learning through density clustering.*/
public class Alec {/*** The whole dataset.*/Instances dataset;/*** The maximal number of queries that can be provided.*/int maxNumQuery;/*** The actual number of queries.*/int numQuery;/*** The radius, also dc in the paper. It is employed for density computation.*/double radius;/*** The densities of instances, also rho in the paper.*/double[] densities;/*** distanceToMaster*/double[] distanceToMaster;/*** Sorted indices, where the first element indicates the instance with the* biggest density.*/int[] descendantDensities;/*** Priority*/double[] priority;/*** The maximal distance between any pair of points.*/double maximalDistance;/*** Who is my master?*/int[] masters;/*** Predicted labels.*/int[] predictedLabels;/*** Instance status. 0 for unprocessed, 1 for queried, 2 for classified.*/int[] instanceStatusArray;/*** The descendant indices to show the representativeness of instances in a* descendant order.*/int[] descendantRepresentatives;/*** Indicate the cluster of each instance. It is only used in* clusterInTwo(int[]);*/int[] clusterIndices;/*** Blocks with size no more than this threshold should not be split further.*/int smallBlockThreshold = 3;/************************************* The constructor.** @param paraFilename*            The data filename.***********************************/public Alec(String paraFilename) {try {FileReader tempReader = new FileReader(paraFilename);dataset = new Instances(tempReader);dataset.setClassIndex(dataset.numAttributes() - 1);tempReader.close();} catch (Exception ee) {System.out.println(ee);System.exit(0);} // Of frycomputeMaximalDistance();clusterIndices = new int[dataset.numInstances()];}// Of the constructor/************************************* Merge sort in descendant order to obtain an index array. The original* array is unchanged. The method should be tested further. <br>* Examples: input [1.2, 2.3, 0.4, 0.5], output [1, 0, 3, 2]. <br>* input [3.1, 5.2, 6.3, 2.1, 4.4], output [2, 1, 4, 0, 3].** @param paraArray*            the original array* @return The sorted indices.***********************************/public static int[] mergeSortToIndices(double[] paraArray) {int tempLength = paraArray.length;int[][] resultMatrix = new int[2][tempLength];// For merge sort.// Initializeint tempIndex = 0;for (int i = 0; i < tempLength; i++) {resultMatrix[tempIndex][i] = i;} // Of for i// Mergeint tempCurrentLength = 1;// The indices for current merged groups.int tempFirstStart, tempSecondStart, tempSecondEnd;while (tempCurrentLength < tempLength) {// Divide into a number of groups.// Here the boundary is adaptive to array length not equal to 2^k.for (int i = 0; i < Math.ceil((tempLength + 0.0) / tempCurrentLength / 2); i++) {// Boundaries of the grouptempFirstStart = i * tempCurrentLength * 2;tempSecondStart = tempFirstStart + tempCurrentLength;tempSecondEnd = tempSecondStart + tempCurrentLength - 1;if (tempSecondEnd >= tempLength) {tempSecondEnd = tempLength - 1;} // Of if// Merge this groupint tempFirstIndex = tempFirstStart;int tempSecondIndex = tempSecondStart;int tempCurrentIndex = tempFirstStart;if (tempSecondStart >= tempLength) {for (int j = tempFirstIndex; j < tempLength; j++) {resultMatrix[(tempIndex + 1) % 2][tempCurrentIndex] = resultMatrix[tempIndex% 2][j];tempFirstIndex++;tempCurrentIndex++;} // Of for jbreak;} // Of ifwhile ((tempFirstIndex <= tempSecondStart - 1)&& (tempSecondIndex <= tempSecondEnd)) {if (paraArray[resultMatrix[tempIndex% 2][tempFirstIndex]] >= paraArray[resultMatrix[tempIndex% 2][tempSecondIndex]]) {resultMatrix[(tempIndex + 1) % 2][tempCurrentIndex] = resultMatrix[tempIndex% 2][tempFirstIndex];tempFirstIndex++;} else {resultMatrix[(tempIndex + 1) % 2][tempCurrentIndex] = resultMatrix[tempIndex% 2][tempSecondIndex];tempSecondIndex++;} // Of iftempCurrentIndex++;} // Of while// Remaining partfor (int j = tempFirstIndex; j < tempSecondStart; j++) {resultMatrix[(tempIndex + 1) % 2][tempCurrentIndex] = resultMatrix[tempIndex% 2][j];tempCurrentIndex++;} // Of for jfor (int j = tempSecondIndex; j <= tempSecondEnd; j++) {resultMatrix[(tempIndex + 1) % 2][tempCurrentIndex] = resultMatrix[tempIndex% 2][j];tempCurrentIndex++;} // Of for j} // Of for itempCurrentLength *= 2;tempIndex++;} // Of whilereturn resultMatrix[tempIndex % 2];}// Of mergeSortToIndices/************************ The Euclidean distance between two instances. Other distance measures* unsupported for simplicity.*** @param paraI*            The index of the first instance.* @param paraJ*            The index of the second instance.* @return The distance.**********************/public double distance(int paraI, int paraJ) {double resultDistance = 0;double tempDifference;for (int i = 0; i < dataset.numAttributes() - 1; i++) {tempDifference = dataset.instance(paraI).value(i) - dataset.instance(paraJ).value(i);resultDistance += tempDifference * tempDifference;} // Of for iresultDistance = Math.sqrt(resultDistance);return resultDistance;}// Of distance/************************************* Compute the maximal distance. The result is stored in a member variable.***********************************/public void computeMaximalDistance() {maximalDistance = 0;double tempDistance;for (int i = 0; i < dataset.numInstances(); i++) {for (int j = 0; j < dataset.numInstances(); j++) {tempDistance = distance(i, j);if (maximalDistance < tempDistance) {maximalDistance = tempDistance;} // Of if} // Of for j} // Of for iSystem.out.println("maximalDistance = " + maximalDistance);}// Of computeMaximalDistance/********************* Compute the densities using Gaussian kernel.*******************/public void computeDensitiesGaussian() {System.out.println("radius = " + radius);densities = new double[dataset.numInstances()];double tempDistance;for (int i = 0; i < dataset.numInstances(); i++) {for (int j = 0; j < dataset.numInstances(); j++) {tempDistance = distance(i, j);densities[i] += Math.exp(-tempDistance * tempDistance / radius / radius);} // Of for j} // Of for iSystem.out.println("The densities are " + Arrays.toString(densities) + "\r\n");}// Of computeDensitiesGaussian/************************************* Compute distanceToMaster, the distance to its master.***********************************/public void computeDistanceToMaster() {distanceToMaster = new double[dataset.numInstances()];masters = new int[dataset.numInstances()];descendantDensities = new int[dataset.numInstances()];instanceStatusArray = new int[dataset.numInstances()];descendantDensities = mergeSortToIndices(densities);distanceToMaster[descendantDensities[0]] = maximalDistance;double tempDistance;for (int i = 1; i < dataset.numInstances(); i++) {// Initialize.distanceToMaster[descendantDensities[i]] = maximalDistance;for (int j = 0; j <= i - 1; j++) {tempDistance = distance(descendantDensities[i], descendantDensities[j]);if (distanceToMaster[descendantDensities[i]] > tempDistance) {distanceToMaster[descendantDensities[i]] = tempDistance;masters[descendantDensities[i]] = descendantDensities[j];} // Of if} // Of for j} // Of for iSystem.out.println("First compute, masters = " + Arrays.toString(masters));System.out.println("descendantDensities = " + Arrays.toString(descendantDensities));}// Of computeDistanceToMaster/************************************* Compute priority. Element with higher priority is more likely to be* selected as a cluster center. Now it is rho * distanceToMaster. It can* also be rho^alpha * distanceToMaster.***********************************/public void computePriority() {priority = new double[dataset.numInstances()];for (int i = 0; i < dataset.numInstances(); i++) {priority[i] = densities[i] * distanceToMaster[i];} // Of for i}// Of computePriority/**************************** The block of a node should be same as its master. This recursive method* is efficient.** @param paraIndex*            The index of the given node.* @return The cluster index of the current node.**************************/public int coincideWithMaster(int paraIndex) {if (clusterIndices[paraIndex] == -1) {int tempMaster = masters[paraIndex];clusterIndices[paraIndex] = coincideWithMaster(tempMaster);} // Of ifreturn clusterIndices[paraIndex];}// Of coincideWithMaster/**************************** Cluster a block in two. According to the master tree.** @param paraBlock*            The given block.* @return The new blocks where the two most represent instances serve as*         the root.**************************/public int[][] clusterInTwo(int[] paraBlock) {// Reinitialize. In fact, only instances in the given block is// considered.Arrays.fill(clusterIndices, -1);// Initialize the cluster number of the two roots.for (int i = 0; i < 2; i++) {clusterIndices[paraBlock[i]] = i;} // Of for ifor (int i = 0; i < paraBlock.length; i++) {if (clusterIndices[paraBlock[i]] != -1) {// Already have a cluster number.continue;} // Of ifclusterIndices[paraBlock[i]] = coincideWithMaster(masters[paraBlock[i]]);} // Of for i// The sub blocks.int[][] resultBlocks = new int[2][];int tempFistBlockCount = 0;for (int i = 0; i < clusterIndices.length; i++) {if (clusterIndices[i] == 0) {tempFistBlockCount++;} // Of if} // Of for iresultBlocks[0] = new int[tempFistBlockCount];resultBlocks[1] = new int[paraBlock.length - tempFistBlockCount];// Copy. You can design shorter code when the number of clusters is// greater than 2.int tempFirstIndex = 0;int tempSecondIndex = 0;for (int i = 0; i < paraBlock.length; i++) {if (clusterIndices[paraBlock[i]] == 0) {resultBlocks[0][tempFirstIndex] = paraBlock[i];tempFirstIndex++;} else {resultBlocks[1][tempSecondIndex] = paraBlock[i];tempSecondIndex++;} // Of if} // Of for iSystem.out.println("Split (" + paraBlock.length + ") instances "+ Arrays.toString(paraBlock) + "\r\nto (" + resultBlocks[0].length + ") instances "+ Arrays.toString(resultBlocks[0]) + "\r\nand (" + resultBlocks[1].length+ ") instances " + Arrays.toString(resultBlocks[1]));return resultBlocks;}// Of clusterInTwo/************************************* Classify instances in the block by simple voting.** @param paraBlock*            The given block.***********************************/public void vote(int[] paraBlock) {int[] tempClassCounts = new int[dataset.numClasses()];for (int i = 0; i < paraBlock.length; i++) {if (instanceStatusArray[paraBlock[i]] == 1) {tempClassCounts[(int) dataset.instance(paraBlock[i]).classValue()]++;} // Of if} // Of for iint tempMaxClass = -1;int tempMaxCount = -1;for (int i = 0; i < tempClassCounts.length; i++) {if (tempMaxCount < tempClassCounts[i]) {tempMaxClass = i;tempMaxCount = tempClassCounts[i];} // Of if} // Of for i// Classify unprocessed instances.for (int i = 0; i < paraBlock.length; i++) {if (instanceStatusArray[paraBlock[i]] == 0) {predictedLabels[paraBlock[i]] = tempMaxClass;instanceStatusArray[paraBlock[i]] = 2;} // Of if} // Of for i}// Of vote/************************************* Cluster based active learning. Prepare for** @param paraRatio*            The ratio of the maximal distance as the dc.* @param paraMaxNumQuery*            The maximal number of queries for the whole dataset.* @parm paraSmallBlockThreshold The small block threshold.***********************************/public void clusterBasedActiveLearning(double paraRatio, int paraMaxNumQuery,int paraSmallBlockThreshold) {radius = maximalDistance * paraRatio;smallBlockThreshold = paraSmallBlockThreshold;maxNumQuery = paraMaxNumQuery;predictedLabels = new int[dataset.numInstances()];for (int i = 0; i < dataset.numInstances(); i++) {predictedLabels[i] = -1;} // Of for icomputeDensitiesGaussian();computeDistanceToMaster();computePriority();descendantRepresentatives = mergeSortToIndices(priority);System.out.println("descendantRepresentatives = " + Arrays.toString(descendantRepresentatives));numQuery = 0;clusterBasedActiveLearning(descendantRepresentatives);}// Of clusterBasedActiveLearning/************************************* Cluster based active learning.** @param paraBlock*            The given block. This block must be sorted according to the*            priority in descendant order.***********************************/public void clusterBasedActiveLearning(int[] paraBlock) {System.out.println("clusterBasedActiveLearning for block " + Arrays.toString(paraBlock));// Step 1. How many labels are queried for this block.int tempExpectedQueries = (int) Math.sqrt(paraBlock.length);int tempNumQuery = 0;for (int i = 0; i < paraBlock.length; i++) {if (instanceStatusArray[paraBlock[i]] == 1) {tempNumQuery++;} // Of if} // Of for i// Step 2. Vote for small blocks.if ((tempNumQuery >= tempExpectedQueries) && (paraBlock.length <= smallBlockThreshold)) {System.out.println("" + tempNumQuery + " instances are queried, vote for block: \r\n"+ Arrays.toString(paraBlock));vote(paraBlock);return;} // Of if// Step 3. Query enough labels.for (int i = 0; i < tempExpectedQueries; i++) {if (numQuery >= maxNumQuery) {System.out.println("No more queries are provided, numQuery = " + numQuery + ".");vote(paraBlock);return;} // Of ifif (instanceStatusArray[paraBlock[i]] == 0) {instanceStatusArray[paraBlock[i]] = 1;predictedLabels[paraBlock[i]] = (int) dataset.instance(paraBlock[i]).classValue();// System.out.println("Query #" + paraBlock[i] + ", numQuery = "// + numQuery);numQuery++;} // Of if} // Of for i// Step 4. Pure?int tempFirstLabel = predictedLabels[paraBlock[0]];boolean tempPure = true;for (int i = 1; i < tempExpectedQueries; i++) {if (predictedLabels[paraBlock[i]] != tempFirstLabel) {tempPure = false;break;} // Of if} // Of for iif (tempPure) {System.out.println("Classify for pure block: " + Arrays.toString(paraBlock));for (int i = tempExpectedQueries; i < paraBlock.length; i++) {if (instanceStatusArray[paraBlock[i]] == 0) {predictedLabels[paraBlock[i]] = tempFirstLabel;instanceStatusArray[paraBlock[i]] = 2;} // Of if} // Of for ireturn;} // Of if// Step 5. Split in two and process them independently.int[][] tempBlocks = clusterInTwo(paraBlock);for (int i = 0; i < 2; i++) {// Attention: recursive invoking here.clusterBasedActiveLearning(tempBlocks[i]);} // Of for i}// Of clusterBasedActiveLearning/********************** Show the statistics information.********************/public String toString() {int[] tempStatusCounts = new int[3];double tempCorrect = 0;for (int i = 0; i < dataset.numInstances(); i++) {tempStatusCounts[instanceStatusArray[i]]++;if (predictedLabels[i] == (int) dataset.instance(i).classValue()) {tempCorrect++;} // Of if} // Of for iString resultString = "(unhandled, queried, classified) = "+ Arrays.toString(tempStatusCounts);resultString += "\r\nCorrect = " + tempCorrect + ", accuracy = "+ (tempCorrect / dataset.numInstances());return resultString;}// Of toString/************************************* The entrance of the program.** @param args:*            Not used now.***********************************/public static void main(String[] args) {long tempStart = System.currentTimeMillis();System.out.println("Starting ALEC.");String arffFilename = "C:\\Users\\86183\\IdeaProjects\\deepLearning\\src\\main\\java\\resources\\iris.arff";//String arffFilename = "C:\\Users\\86183\\IdeaProjects\\deepLearning\\src\\main\\java\\resources\\mushroom.arff";Alec tempAlec = new Alec(arffFilename);// The settings for iristempAlec.clusterBasedActiveLearning(0.15, 30, 3);// The settings for mushroom// tempAlec.clusterBasedActiveLearning(0.1, 800, 3);System.out.println(tempAlec);long tempEnd = System.currentTimeMillis();System.out.println("Runtime: " + (tempEnd - tempStart) + "ms.");}// Of main
}// Of class Alec

结果:

 

相关文章:

Day 66-68 主动学习之ALEC

代码&#xff1a; package dl;import java.io.FileReader; import java.util.*; import weka.core.Instances;/*** Active learning through density clustering.*/ public class Alec {/*** The whole dataset.*/Instances dataset;/*** The maximal number of queries that …...

local-path-provisioner与pvc本地磁盘挂载helm部署

1.helm拉取安装包 helm repo add containeroo https://charts.containeroo.ch helm pull containeroo/local-path-provisioner --version 0.0.19 tar -zxvf local-path-provisioner-0.0.19.tgz cd local-path-provisioner mv values.yaml values.yaml.back grep -v "#&qu…...

Visio/PPT/Matlab输出300dpi以上图片【满足标准投稿要求】

1. visio 遵照如下输出选项&#xff0c;另存为tif格式文件时&#xff0c;选择正确输出便是300dpi以上 2. matlab 文件选项选中导出设置&#xff0c;在渲染中选择dpi为600&#xff0c;导出图片即可&#xff0c;科研建议选择tif格式文件 3.ppt 打开注册表&#xff0c;winr键…...

科技UI图标的制作

科技UI图标的制作&#xff0c;效果图如下&#xff1a; 一、新建合成 1、新建合成&#xff0c;命名为合成1&#xff0c;参数设置如下&#xff1a; 2、新建纯色&#xff0c;命名为分形 二、添加分形杂色 1、添加分形杂色 为纯色层“分形”&#xff0c;添加分形杂色&#xff0c…...

微信小程序将接口返回的文件流预览导出Excel文件并转发

把接口url替换就可以用了 exportExcel () {wx.request({url: importMyApply, //这个地方是你获取二进制流的接口地址method: POST,responseType: "arraybuffer", //特别注意的是此处是请求文件流必须加上的属性&#xff0c;不然你导出到手机上的时候打不开&#xff…...

windows 安装 mongodb 数据库

软件下载 访问官方的下载地址&#xff1a; https://www.mongodb.com/try/download/community &#xff0c;然后选择对应的版本进行下载 下载好了之后双击进行安装 软件安装 1、点击 next 点击下一步 2、勾选接受协议&#xff0c;点击 next 3、第三页有两个选项&#x…...

业务不打烊:解决软件系统升级痛点的新方法

数字化时代&#xff0c;随着用户对产品性能和功能要求的不断提升&#xff0c;应用服务升级成了企业保持竞争力的关键之一。然而&#xff0c;传统的应用服务升级往往会给用户带来不必要的中断和不便&#xff0c;这种“伤筋动骨”的升级方式已经无法满足日益增长的用户需求&#…...

csdn新星计划vue3+ts+antd赛道——利用inscode搭建vue3(ts)+antd前端模板

文章目录 ⭐前言⭐利用inscode免费开放资源&#x1f496; 在inscode搭建vue3tsant项目&#x1f496; 调整配置&#x1f496; antd 国际化配置&#x1f496; 用户store&#x1f496; 路由权限&#x1f496; 预览 ⭐结束 ⭐前言 大家好&#xff0c;我是yma16&#xff0c;本文分享…...

通过 CSS 的样式实现语音发送动效类似声音震动的效果

实现效果&#xff1a;一般用于发送语音的时候&#xff0c;出现动画效果 //模版部分 <view class"musical-scale"><view class"scale"><view class"em" v-for"(item,index) in 15" :key"index"></view…...

【C#】.Net Framework框架使用JWT

2023年&#xff0c;第31周&#xff0c;第2篇文章。给自己一个目标&#xff0c;然后坚持总会有收货&#xff0c;不信你试试&#xff01; 本篇文章主要简单讲讲&#xff0c;.Net Framework框架下使用JWT的代码例子&#xff0c;以及他们的基本概念。 2002年微软发布了.net framewo…...

SQL高级教程第三章

SQL CREATE DATABASE 语句 CREATE DATABASE 语句 CREATE DATABASE 用于创建数据库。 SQL CREATE DATABASE 语法 CREATE DATABASE database_name SQL CREATE DATABASE 实例 现在我们希望创建一个名为 "my_db" 的数据库。 我们使用下面的 CREATE DATABASE 语句&…...

vue 3.0 下载本地pdf文件

使用a标签,把pdf文件放到public文件夹下面 <el-form label-width"160px"> <el-form-item label"使用手册"> <div class"form-item-static"> <a href"/使用手册.pdf" target"_blank" class"link&q…...

平板用的触控笔什么牌子好?ipad第三方电容笔推荐

随着技术的发展&#xff0c;出现了各种各样的平板电容笔。一支好的电容笔&#xff0c;不但可以极大地提升我们的工作效率&#xff0c;还可以极大地提升我们的学习效果。平替的电容笔&#xff0c;无论是在技术方面&#xff0c;还是在质量方面&#xff0c;都还有很大的提升空间&a…...

【Unity2D】相机移动以及设置相机边界

添加相机 添加相机时&#xff0c;首先需要在unity中添加 Cinemachine 包 第一次使用这个包时&#xff0c;需要在Package Manager中搜索并安装 安装Camera Mechine包后&#xff0c;添加2D Camera 设置跟随对象为Ruby &#xff08;从Hierarchy中将Ruby拖动到Follow中&#xff0…...

和chatgpt学架构04-路由开发

目录 1 什么是路由2 如何设置路由2.1 安装依赖2.2 创建路由文件2.3 创建首页2.4 编写HomePage2.5 更新路由配置2.6 让路由生效 3 测试总结 要想使用vue实现页面的灵活跳转&#xff0c;其中路由配置是必不可少的&#xff0c;我们在做开发的时候&#xff0c;先需要了解知识点&…...

Spring MVC异常处理【单个控制异常处理器、全局异常处理器、自定义异常处理器】

目录 一、单个控制器异常处理 1.1 控制器方法 1.2 编写出错页面 1.3 测试结果 二、全局异常处理 2.1 一个有异常的控制器类 2.2 全局异常处理器类 2.3 测试结果 三、自定义异常处理器 3.1 自定义异常处理器 3.2 测试结果 往期专栏&文章相关导读 1. Maven系列…...

使用3ds Max粒子系统创建飞天箭雨特效场景

推荐&#xff1a; NSDT场景编辑器助你快速搭建可二次开发的3D应用场景 1. 设置箭头 步骤 1 打开 3ds Max。 打开 3ds Max 步骤 2 我使用多边形建模技术制作了一个简单的箭头&#xff0c;我将 在教程中使用。.max您可以从 下载部分。 箭头.max 步骤 3 将此箭头重命名为静态…...

【朴素贝叶斯实例】

朴素贝叶斯对新闻进行分类 朴素贝叶斯算法是一种常用的文本分类方法&#xff0c;特别适用于自然语言处理任务&#xff0c;如新闻分类。在这篇博客中&#xff0c;我们将使用Python的scikit-learn库来实现朴素贝叶斯算法&#xff0c;并将其应用于新闻分类任务。 数据准备 首先…...

MPAS跨尺度、可变分辨率模式

跨尺度预测模式&#xff08;The Model for Prediction Across Scales - MPAS&#xff09;是由洛斯阿拉莫斯实验室和美国国家大气研究中心(NCAR)共同开发&#xff0c;其由3个部分组成&#xff0c;分别称为 MPAS-A&#xff08;大气模型&#xff09;、MPAS-O&#xff08;海洋模型&…...

微信小程序对接SSE接口记录

微信小程序对接SSE接口记录 需求&#xff1a;公司项目对接gpt&#xff0c;gpt产生的结果是分段返回&#xff0c;所以要求在产生结果时&#xff0c;有打字机的效果。原本是由定时器调用&#xff0c;后来优化改为服务端使用SSE接口。小程序使用起来比较方便&#xff0c;但是要求…...

java_网络服务相关_gateway_nacos_feign区别联系

1. spring-cloud-starter-gateway 作用&#xff1a;作为微服务架构的网关&#xff0c;统一入口&#xff0c;处理所有外部请求。 核心能力&#xff1a; 路由转发&#xff08;基于路径、服务名等&#xff09;过滤器&#xff08;鉴权、限流、日志、Header 处理&#xff09;支持负…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

电脑插入多块移动硬盘后经常出现卡顿和蓝屏

当电脑在插入多块移动硬盘后频繁出现卡顿和蓝屏问题时&#xff0c;可能涉及硬件资源冲突、驱动兼容性、供电不足或系统设置等多方面原因。以下是逐步排查和解决方案&#xff1a; 1. 检查电源供电问题 问题原因&#xff1a;多块移动硬盘同时运行可能导致USB接口供电不足&#x…...

Golang dig框架与GraphQL的完美结合

将 Go 的 Dig 依赖注入框架与 GraphQL 结合使用&#xff0c;可以显著提升应用程序的可维护性、可测试性以及灵活性。 Dig 是一个强大的依赖注入容器&#xff0c;能够帮助开发者更好地管理复杂的依赖关系&#xff0c;而 GraphQL 则是一种用于 API 的查询语言&#xff0c;能够提…...

第一篇:Agent2Agent (A2A) 协议——协作式人工智能的黎明

AI 领域的快速发展正在催生一个新时代&#xff0c;智能代理&#xff08;agents&#xff09;不再是孤立的个体&#xff0c;而是能够像一个数字团队一样协作。然而&#xff0c;当前 AI 生态系统的碎片化阻碍了这一愿景的实现&#xff0c;导致了“AI 巴别塔问题”——不同代理之间…...

Web 架构之 CDN 加速原理与落地实践

文章目录 一、思维导图二、正文内容&#xff08;一&#xff09;CDN 基础概念1. 定义2. 组成部分 &#xff08;二&#xff09;CDN 加速原理1. 请求路由2. 内容缓存3. 内容更新 &#xff08;三&#xff09;CDN 落地实践1. 选择 CDN 服务商2. 配置 CDN3. 集成到 Web 架构 &#xf…...

使用Matplotlib创建炫酷的3D散点图:数据可视化的新维度

文章目录 基础实现代码代码解析进阶技巧1. 自定义点的大小和颜色2. 添加图例和样式美化3. 真实数据应用示例实用技巧与注意事项完整示例(带样式)应用场景在数据科学和可视化领域,三维图形能为我们提供更丰富的数据洞察。本文将手把手教你如何使用Python的Matplotlib库创建引…...

《C++ 模板》

目录 函数模板 类模板 非类型模板参数 模板特化 函数模板特化 类模板的特化 模板&#xff0c;就像一个模具&#xff0c;里面可以将不同类型的材料做成一个形状&#xff0c;其分为函数模板和类模板。 函数模板 函数模板可以简化函数重载的代码。格式&#xff1a;templa…...

C++课设:简易日历程序(支持传统节假日 + 二十四节气 + 个人纪念日管理)

名人说:路漫漫其修远兮,吾将上下而求索。—— 屈原《离骚》 创作者:Code_流苏(CSDN)(一个喜欢古诗词和编程的Coder😊) 专栏介绍:《编程项目实战》 目录 一、为什么要开发一个日历程序?1. 深入理解时间算法2. 练习面向对象设计3. 学习数据结构应用二、核心算法深度解析…...

Golang——6、指针和结构体

指针和结构体 1、指针1.1、指针地址和指针类型1.2、指针取值1.3、new和make 2、结构体2.1、type关键字的使用2.2、结构体的定义和初始化2.3、结构体方法和接收者2.4、给任意类型添加方法2.5、结构体的匿名字段2.6、嵌套结构体2.7、嵌套匿名结构体2.8、结构体的继承 3、结构体与…...