- K近邻算法_分类鸢尾花数据集
_feivirus_
算法机器学习和数学分类机器学习K近邻
importnumpyasnpimportpandasaspdfromsklearn.datasetsimportload_irisfromsklearn.model_selectionimporttrain_test_splitfromsklearn.metricsimportaccuracy_score1.数据预处理iris=load_iris()df=pd.DataFrame(data=ir
- COCO 格式的数据集转化为 YOLO 格式的数据集
QYQY77
YOLOpython
"""--json_path输入的json文件路径--save_path保存的文件夹名字,默认为当前目录下的labels。"""importosimportjsonfromtqdmimporttqdmimportargparseparser=argparse.ArgumentParser()parser.add_argument('--json_path',default='./instances
- Python3.7出现“ModuleNotFoundError: No module named ‘Tkinter‘”错误的解决方法
可爱的小红猪
python
Python3.7出现“ModuleNotFoundError:Nomodulenamed‘Tkinter’”错误的解决方法在网上看到很多针对这个问题的解决方法都是重新安装或配置Tkinter库,但Tkinter是python内置的标准GUI库,安装Python时就已经内置在了库中,不需要另外下载。针对于Tkinter,你的代码很可能是这样的:importTkinter或者是这样fromTkint
- 重载new,delete , RTTI,类成员指针
森龙安
C++c++
重载new,delete执行过程重载new,delete和普通的运算符重载不同,并非重载new,delete的行为,而是改变内存分配的方式,将对象放置在特定的内存空间中new运算符操作:调用STL标准模板库的重载operatornew或operatornew[]函数,分配足够大的未命名内存运行相应构造函数返回指向对象的指针delete运算符操作:运行相应折构函数、调用STL标准模板库的重载oper
- SAP自动化-ME12批量更新最后一行的价格
小九不懂SAP
自动化SAPpython
Python源码#-Begin-----------------------------------------------------------------#-Includes--------------------------------------------------------------importsys,win32com.clientimportosimporttime#-Sub
- python画出分子化学空间分布(UMAP)
Sakaiay
python
利用umap画出分子化学空间分布图安装pipinstallumap-learn下面是用一个数据集举的例子importtorchimportumapimportpandasaspdimportnumpyasnpimportmatplotlib.pyplotaspltimportseabornassnsfromsklearn.manifoldimportTSNEfromrdkit.Chemimport
- Python 模块导入方式
小丫头呀
#Python随笔python开发语言
在Python中,导入外部模块有2种方式以Pyhton自带的time模块为例:使用importtime导入方式importtimeprint(time.ctime())注意事项:time模块导入后,使用以下格式来调用模块中的函数:模块名.函数名如果导入的模块名称很长,可以使用as也就是别名的方式,给模块取个自定义的别名。例如:importtimeast;使用示例:t.ctime()使用fromti
- 随摘
桔桔岛
Oneshouldcaremoreaboutone'sowngrowthinsteadofothers.Toliveahappylife,oneshouldalwaystryeveryefforttominimizeregretsinlife.比起时刻注视着他人,多关注自身的成长,尽自己的一切努力让生活少点遗憾,才能过上快意人生。Whenoneshiftstheirfocusfromotherst
- python 多线程抓取xunlei磁力下载链接
weixin_53748624
pythonpycharm
importurllib.requestimportreimporttimeimportthreadingclassSpider(object):def__init__(self):#定义字典,用于保存影片信息self.films_dict={}self.i=1self.lock1=threading.Lock()defstart(self):#调用下载函数,获取下载连接forpageinrang
- 深度学习:怎么看pth文件的参数
奥利给少年
深度学习人工智能
.pth文件是PyTorch模型的权重文件,它通常包含了训练好的模型的参数。要查看或使用这个文件,你可以按照以下步骤操作:1.确保你有模型的定义你需要有创建这个.pth文件时所用的模型的代码。这意味着你需要有模型的类定义和架构。2.加载模型权重使用PyTorch的load_state_dict方法来加载权重。这里是如何操作的:importtorchimporttorch.nnasnn#定义模型结构
- groupby 中如何显示 tqdm 的进度条?
domodo2020
在循环时调用tqdm显示进度已经是一个常规操作,常见的方式是foriiintqdm(...):...while循环的情况类似,whileicntintqdm(range(n)):...icnt+=1这里记录没有显式循环时,在groupby中的用法:importpandasaspdimportnumpyasnpfromtqdmimporttqdmdf=pd.DataFrame(np.random.r
- JAVA常用校验注解
小卡车555
java
引入依赖org.springframeworkspring-boot-starter-validation2.6.13相关注解及使用说明注解描述@AssertFalse所注解的元素必须是Boolean类型,且值为false@AssertTrue所注解的元素必须是Boolean类型,且值为true@DecimalMin验证Number和String对象是否大于等于指定的值,支持小数@DecimalM
- Python 将parquet文件转换为csv文件
一个小坑货
#python常用功能方法python开发语言
Python将parquet文件转换为csv文件使用pyarrow插件将parquet文件转换为csv使用pyarrow插件将parquet文件转换为csv```pythonimportosimportpyarrow.parquetaspqfromconcurrent.futuresimportThreadPoolExecutorimportcsvimporttime#定义一个函数来处理单个Par
- 基于Python实现一个庆祝国庆节的小程序
LQS2020
python小程序pygame
功能:添加互动功能:允许用户选择不同的祝福语或者查询不同的国庆节信息。动态背景音乐:播放国庆节相关的背景音乐。增加节日小测验:提供一些关于国庆节的趣味小测验,让用户参与。增强图形用户界面(GUI):使用更多的tkinter控件,比如按钮、复选框等,使界面更加丰富和互动。下面是一个更全面的示例代码,包括以上的改进:完整代码示例importtkinterastkfromtkinterimportPho
- VueTreeselect el-tree-select 多选
小小并不小
Vueelementjsvue.jsjavascript
1、VueTreeselect是一个多选组件npminstall--save@riophae/vue-treeselect全部代码//importthecomponentimportTreeselectfrom'@riophae/vue-treeselect'//importthestylesimport'@riophae/vue-treeselect/dist/vue-treeselect.cs
- 【Leetcode】581. Shortest Unsorted Continuous Subarray
云端漫步_b5aa
Givenanintegerarray,youneedtofindonecontinuoussubarraythatifyouonlysortthissubarrayinascendingorder,thenthewholearraywillbesortedinascendingorder,too.Youneedtofindtheshortestsuchsubarrayandoutputitsle
- 深入解读《Python之禅》:用实战代码诠释Python编程哲学20240914
Narutolxy
Python笔记技术干货分享python开发语言
深入解读《Python之禅》:用实战代码诠释Python编程哲学《Python之禅》(TheZenofPython)是Python语言的设计哲学,由TimPeters总结,包含了19条简洁而深刻的格言。当你在Python解释器中输入importthis时,这些格言便会展现在你的眼前。它们不仅仅是简单的句子,更是指导Python程序员编写优雅、简洁、可读代码的准则。本文将结合实际的最佳实践代码,逐条
- 盘点一个Python网络爬虫抓取股票代码问题(上篇)
皮皮_f075
大家好,我是皮皮。一、前言前几天在Python白银群【厚德载物】问了一个Python网络爬虫的问题,这里拿出来给大家分享下。image.png二、实现过程这个问题其实for循环就可以搞定了,看上去粉丝的代码没有带请求头那些,导致获取不到数据。后来【瑜亮老师】、【小王子】给了具体思路,代码如下图所示:image.png后来【小王子】也给了一个具体代码,如下:importrequestsimportt
- 大模型微调 - 基于预训练大语言模型的对话生成任务 训练代码
西笑生
大模型大模型自然语言处理微调
大模型微调-基于预训练大语言模型的对话生成任务训练代码flyfish模型扮演堂吉诃德这个角色,回答关于自我介绍的问题importtorchfromdatasetsimportDatasetfrommodelscopeimportAutoTokenizer,AutoModelForCausalLMfrompeftimportLoraConfig,TaskType,get_peft_modelfrom
- Django 创建好的模块怎么在后台显示
u010373106
pythonDjangodjango数据库sqlite
1、配置模型及其需要显示的数据刚才创建好的tests的增删改查,在后台是不显示的,所以需要进行配置,在刚才创建好的模块里找到admin.py文件,在里面进行如下配置fromdjango.contribimportadminfrom.importmodelsfrom.modelsimportTests#Registeryourmodelshere.classTestsAdmin(admin.Mode
- 浅析MYSQL的事务和锁
胡萝卜、
mysql数据库java
1.MySQL的事务和锁1.1事务的介绍:概念:事务指逻辑上的一组操作,组成这个操作的单元,要么全部成功执行,要么全部执行失败个人理解:某个业务执行更新语句,整个业务下得sql语句(单指更新)全部成功执行,或者执行全部失败常见的mysql执行命令:starttransaction开启事务rollback回滚事务commit提交事务showvariableslike'%commit';查询是否为自动
- 重磅算法:通信设备虚拟仿真-波形根据频率、带宽变化算法(Vue3+typescript)结尾附vue2+JavaScript
I like Code?
javascript算法typescript
以下为Vue3+typescriptconstpointSpacing=ref(0);constupdateInterval=ref(undefined);//更新图表数据的函数constUpdateChartTest=(centerFrequnency:number,bandwidth:number,baseFreq=800,baseBW=100)=>{if(updateInterval.val
- 解决ModuleNotFoundError: No module named ‘torch的方法
梅菊林
各种问题解决方案开发语言
ModuleNotFoundError:Nomodulenamed‘torch’错误是Python在尝试导入名为torch的模块时找不到该模块而抛出的异常。torch是PyTorch深度学习框架的核心库,如果你的Python环境中没有安装这个库,尝试导入时就会遇到这个错误。文章目录报错问题报错原因解决方法报错问题当你尝试在Python脚本或交互式环境中执行以下命令时:importtorch如果Py
- bigquery_到Google bigquery的sql查询模板,它将您的报告提升到另一个层次
张_伟_杰
javamysqlsqlpython数据库
bigqueryInthispost,we’resharingreporttemplatesthatyoucanbuildwithSQLqueriestoGoogleBigQuerydata.在本文中,我们将分享您可以使用SQL查询为GoogleBigQuery数据构建的报告模板。First,you’llfindoutaboutwhatyoucancalculatewiththestandarde
- java字符串转对象数组_将字符串数组转为java对象
凯米拉诺
java字符串转对象数组
最近在工作中,遇到一个场景:接受到一个字符串数组,需要将其转为一个对象,反射实现的方法如下:/***将字符串数组转成对象:支持doubleintbooleanstring*@paramvalueList值数组列表*@paramproperties属性数组*@paramc目标class对象*@return返回null时丢弃此结果*/publicListconvertToDomain(Listvalu
- pdf转换jpg(Python版本3.10)
大头安
pythonpythonpdf数学建模
importosimportrefromPILimportImagefrompdf2imageimportconvert_from_path,exceptionsfromconcurrent.futuresimportProcessPoolExecutorimporttempfile#解除Pillow的像素限制Image.MAX_IMAGE_PIXELS=Nonechunk_size=10#每个块
- Python中item()和items()的用处
~|Bernard|
深度学习疑点总结pythonpytorch深度学习
item()区别一:在pytorch训练时,一般用到.item()。比如loss.item()。我们可以做个简单测试代码看看它的区别:importtorchx=torch.randn(2,2)print(x)print(x[1,1])print(x[1,1].item())运行结果:tensor([[-2.0743,0.1675],[0.7016,-0.6779]])tensor(-0.6779)
- TextCNN:文本卷积神经网络模型
一只天蝎
编程语言---Pythoncnn深度学习机器学习
目录什么是TextCNN定义TextCNN类初始化一个model实例输出model什么是TextCNNTextCNN(TextConvolutionalNeuralNetwork)是一种用于处理文本数据的卷积神经网(CNN)。通过在文本数据上应用卷积操作来提取局部特征,这些特征可以捕捉到文本中的局部模式,如n-gram(连续的n个单词或字符)。定义TextCNN类importtorch.nnasn
- TS axios封装
小白小白从不日白
TypeScript前端typescript
方式一service/request/request.tsimportaxiosfrom'axios'import{ElLoading}from'element-plus'importtype{AxiosRequestConfig,AxiosInstance,AxiosResponse}from'axios'importtype{ILoadingInstance}from'element-plus
- QLoRa使用教程
云帆@
训练peft人工智能
一、定义定义案例1二、实现定义QLoRa:量化+LoRa.网址:https://huggingface.co/docs/peft/main/en/developer_guides/quantization案例11.4bit量化+LoRaimporttorchfromtransformersimportBitsAndBytesConfigconfig=BitsAndBytesConfig(load_
- 戴尔笔记本win8系统改装win7系统
sophia天雪
win7戴尔改装系统win8
戴尔win8 系统改装win7 系统详述
第一步:使用U盘制作虚拟光驱:
1)下载安装UltraISO:注册码可以在网上搜索。
2)启动UltraISO,点击“文件”—》“打开”按钮,打开已经准备好的ISO镜像文
- BeanUtils.copyProperties使用笔记
bylijinnan
java
BeanUtils.copyProperties VS PropertyUtils.copyProperties
两者最大的区别是:
BeanUtils.copyProperties会进行类型转换,而PropertyUtils.copyProperties不会。
既然进行了类型转换,那BeanUtils.copyProperties的速度比不上PropertyUtils.copyProp
- MyEclipse中文乱码问题
0624chenhong
MyEclipse
一、设置新建常见文件的默认编码格式,也就是文件保存的格式。
在不对MyEclipse进行设置的时候,默认保存文件的编码,一般跟简体中文操作系统(如windows2000,windowsXP)的编码一致,即GBK。
在简体中文系统下,ANSI 编码代表 GBK编码;在日文操作系统下,ANSI 编码代表 JIS 编码。
Window-->Preferences-->General -
- 发送邮件
不懂事的小屁孩
send email
import org.apache.commons.mail.EmailAttachment;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.commons.mail.MultiPartEmail;
- 动画合集
换个号韩国红果果
htmlcss
动画 指一种样式变为另一种样式 keyframes应当始终定义0 100 过程
1 transition 制作鼠标滑过图片时的放大效果
css
.wrap{
width: 340px;height: 340px;
position: absolute;
top: 30%;
left: 20%;
overflow: hidden;
bor
- 网络最常见的攻击方式竟然是SQL注入
蓝儿唯美
sql注入
NTT研究表明,尽管SQL注入(SQLi)型攻击记录详尽且为人熟知,但目前网络应用程序仍然是SQLi攻击的重灾区。
信息安全和风险管理公司NTTCom Security发布的《2015全球智能威胁风险报告》表明,目前黑客攻击网络应用程序方式中最流行的,要数SQLi攻击。报告对去年发生的60亿攻击 行为进行分析,指出SQLi攻击是最常见的网络应用程序攻击方式。全球网络应用程序攻击中,SQLi攻击占
- java笔记2
a-john
java
类的封装:
1,java中,对象就是一个封装体。封装是把对象的属性和服务结合成一个独立的的单位。并尽可能隐藏对象的内部细节(尤其是私有数据)
2,目的:使对象以外的部分不能随意存取对象的内部数据(如属性),从而使软件错误能够局部化,减少差错和排错的难度。
3,简单来说,“隐藏属性、方法或实现细节的过程”称为——封装。
4,封装的特性:
4.1设置
- [Andengine]Error:can't creat bitmap form path “gfx/xxx.xxx”
aijuans
学习Android遇到的错误
最开始遇到这个错误是很早以前了,以前也没注意,只当是一个不理解的bug,因为所有的texture,textureregion都没有问题,但是就是提示错误。
昨天和美工要图片,本来是要背景透明的png格式,可是她却给了我一个jpg的。说明了之后她说没法改,因为没有png这个保存选项。
我就看了一下,和她要了psd的文件,还好我有一点
- 自己写的一个繁体到简体的转换程序
asialee
java转换繁体filter简体
今天调研一个任务,基于java的filter实现繁体到简体的转换,于是写了一个demo,给各位博友奉上,欢迎批评指正。
实现的思路是重载request的调取参数的几个方法,然后做下转换。
- android意图和意图监听器技术
百合不是茶
android显示意图隐式意图意图监听器
Intent是在activity之间传递数据;Intent的传递分为显示传递和隐式传递
显式意图:调用Intent.setComponent() 或 Intent.setClassName() 或 Intent.setClass()方法明确指定了组件名的Intent为显式意图,显式意图明确指定了Intent应该传递给哪个组件。
隐式意图;不指明调用的名称,根据设
- spring3中新增的@value注解
bijian1013
javaspring@Value
在spring 3.0中,可以通过使用@value,对一些如xxx.properties文件中的文件,进行键值对的注入,例子如下:
1.首先在applicationContext.xml中加入:
<beans xmlns="http://www.springframework.
- Jboss启用CXF日志
sunjing
logjbossCXF
1. 在standalone.xml配置文件中添加system-properties:
<system-properties> <property name="org.apache.cxf.logging.enabled" value=&
- 【Hadoop三】Centos7_x86_64部署Hadoop集群之编译Hadoop源代码
bit1129
centos
编译必需的软件
Firebugs3.0.0
Maven3.2.3
Ant
JDK1.7.0_67
protobuf-2.5.0
Hadoop 2.5.2源码包
Firebugs3.0.0
http://sourceforge.jp/projects/sfnet_findbug
- struts2验证框架的使用和扩展
白糖_
框架xmlbeanstruts正则表达式
struts2能够对前台提交的表单数据进行输入有效性校验,通常有两种方式:
1、在Action类中通过validatexx方法验证,这种方式很简单,在此不再赘述;
2、通过编写xx-validation.xml文件执行表单验证,当用户提交表单请求后,struts会优先执行xml文件,如果校验不通过是不会让请求访问指定action的。
本文介绍一下struts2通过xml文件进行校验的方法并说
- 记录-感悟
braveCS
感悟
再翻翻以前写的感悟,有时会发现自己很幼稚,也会让自己找回初心。
2015-1-11 1. 能在工作之余学习感兴趣的东西已经很幸福了;
2. 要改变自己,不能这样一直在原来区域,要突破安全区舒适区,才能提高自己,往好的方面发展;
3. 多反省多思考;要会用工具,而不是变成工具的奴隶;
4. 一天内集中一个定长时间段看最新资讯和偏流式博
- 编程之美-数组中最长递增子序列
bylijinnan
编程之美
import java.util.Arrays;
import java.util.Random;
public class LongestAccendingSubSequence {
/**
* 编程之美 数组中最长递增子序列
* 书上的解法容易理解
* 另一方法书上没有提到的是,可以将数组排序(由小到大)得到新的数组,
* 然后求排序后的数组与原数
- 读书笔记5
chengxuyuancsdn
重复提交struts2的token验证
1、重复提交
2、struts2的token验证
3、用response返回xml时的注意
1、重复提交
(1)应用场景
(1-1)点击提交按钮两次。
(1-2)使用浏览器后退按钮重复之前的操作,导致重复提交表单。
(1-3)刷新页面
(1-4)使用浏览器历史记录重复提交表单。
(1-5)浏览器重复的 HTTP 请求。
(2)解决方法
(2-1)禁掉提交按钮
(2-2)
- [时空与探索]全球联合进行第二次费城实验的可能性
comsci
二次世界大战前后,由爱因斯坦参加的一次在海军舰艇上进行的物理学实验 -费城实验
至今给我们大家留下很多迷团.....
关于费城实验的详细过程,大家可以在网络上搜索一下,我这里就不详细描述了
在这里,我的意思是,现在
- easy connect 之 ORA-12154: TNS: 无法解析指定的连接标识符
daizj
oracleORA-12154
用easy connect连接出现“tns无法解析指定的连接标示符”的错误,如下:
C:\Users\Administrator>sqlplus username/
[email protected]:1521/orcl
SQL*Plus: Release 10.2.0.1.0 – Production on 星期一 5月 21 18:16:20 2012
Copyright (c) 198
- 简单排序:归并排序
dieslrae
归并排序
public void mergeSort(int[] array){
int temp = array.length/2;
if(temp == 0){
return;
}
int[] a = new int[temp];
int
- C语言中字符串的\0和空格
dcj3sjt126com
c
\0 为字符串结束符,比如说:
abcd (空格)cdefg;
存入数组时,空格作为一个字符占有一个字节的空间,我们
- 解决Composer国内速度慢的办法
dcj3sjt126com
Composer
用法:
有两种方式启用本镜像服务:
1 将以下配置信息添加到 Composer 的配置文件 config.json 中(系统全局配置)。见“例1”
2 将以下配置信息添加到你的项目的 composer.json 文件中(针对单个项目配置)。见“例2”
为了避免安装包的时候都要执行两次查询,切记要添加禁用 packagist 的设置,如下 1 2 3 4 5
- 高效可伸缩的结果缓存
shuizhaosi888
高效可伸缩的结果缓存
/**
* 要执行的算法,返回结果v
*/
public interface Computable<A, V> {
public V comput(final A arg);
}
/**
* 用于缓存数据
*/
public class Memoizer<A, V> implements Computable<A,
- 三点定位的算法
haoningabc
c算法
三点定位,
已知a,b,c三个顶点的x,y坐标
和三个点都z坐标的距离,la,lb,lc
求z点的坐标
原理就是围绕a,b,c 三个点画圆,三个圆焦点的部分就是所求
但是,由于三个点的距离可能不准,不一定会有结果,
所以是三个圆环的焦点,环的宽度开始为0,没有取到则加1
运行
gcc -lm test.c
test.c代码如下
#include "stdi
- epoll使用详解
jimmee
clinux服务端编程epoll
epoll - I/O event notification facility在linux的网络编程中,很长的时间都在使用select来做事件触发。在linux新的内核中,有了一种替换它的机制,就是epoll。相比于select,epoll最大的好处在于它不会随着监听fd数目的增长而降低效率。因为在内核中的select实现中,它是采用轮询来处理的,轮询的fd数目越多,自然耗时越多。并且,在linu
- Hibernate对Enum的映射的基本使用方法
linzx0212
enumHibernate
枚举
/**
* 性别枚举
*/
public enum Gender {
MALE(0), FEMALE(1), OTHER(2);
private Gender(int i) {
this.i = i;
}
private int i;
public int getI
- 第10章 高级事件(下)
onestopweb
事件
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/
- 孙子兵法
roadrunners
孙子兵法
始计第一
孙子曰:
兵者,国之大事,死生之地,存亡之道,不可不察也。
故经之以五事,校之以计,而索其情:一曰道,二曰天,三曰地,四曰将,五
曰法。道者,令民于上同意,可与之死,可与之生,而不危也;天者,阴阳、寒暑
、时制也;地者,远近、险易、广狭、死生也;将者,智、信、仁、勇、严也;法
者,曲制、官道、主用也。凡此五者,将莫不闻,知之者胜,不知之者不胜。故校
之以计,而索其情,曰
- MySQL双向复制
tomcat_oracle
mysql
本文包括:
主机配置
从机配置
建立主-从复制
建立双向复制
背景
按照以下简单的步骤:
参考一下:
在机器A配置主机(192.168.1.30)
在机器B配置从机(192.168.1.29)
我们可以使用下面的步骤来实现这一点
步骤1:机器A设置主机
在主机中打开配置文件 ,
- zoj 3822 Domination(dp)
阿尔萨斯
Mina
题目链接:zoj 3822 Domination
题目大意:给定一个N∗M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望。
解题思路:大白书上概率那一张有一道类似的题目,但是因为时间比较久了,还是稍微想了一下。dp[i][j][k]表示i行j列上均有至少一枚棋子,并且消耗k步的概率(k≤i∗j),因为放置在i+1~n上等价与放在i+1行上,同理