Python
光子乘羽
我从来没有长大,也从来没有停止过成长。
展开
-
python读取csv文件指定行
if index == 6+k*11 or index == 7+k*11 or index == 8+k*11 or index == 9+k*11 or index == 10+k*11:#目标行。results=np.array(results).astype(float)#直接读取的数据是str 转float。elif index % 11 == 10: # 最后一折。if index%11==6:#第一折。# 这是表示读取前10行。原创 2022-10-18 18:03:53 · 7559 阅读 · 0 评论 -
failed to allocate 2.00G (2147483648 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory
显存充足,但是却出现CUDA error:out of memory错误添加:import os# 设置程序使用的GPU编号:我用6号和7号显卡os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'import numpy as npimport kerasimport keras.backend as Kimport tensorflow.compat.v1 as tftf.disable_v2_behavior()import keras.b原创 2022-03-01 20:59:49 · 4769 阅读 · 2 评论 -
python 实现LDA二分类
import torchfrom getData import loadFeatur,loadFeatureByCorrNum,loadFeatureByNormfrom torch_geometric.data import DataLoaderfrom GCNmodel import GCN,GNN,createGNNdatasetimport numpy as npimport randomprint("\n---------Starting to load Data---------.原创 2022-01-11 20:45:43 · 796 阅读 · 0 评论 -
Python读取csv文件列数据,并去除其中的nan行
import numpy as npimport pandas as pd#读取csv文件列数据,并去除其中的nan行def getSubjID(subjBehavFile='D:/HCP documents/HCP1200_behavior.csv'): # 使用pandas读入 behavData = pd.read_csv(subjBehavFile) #读取文件中所有数据 # 按列分离数据 allSubjID = behavData[['Subject']]#读原创 2021-12-26 11:30:15 · 3375 阅读 · 0 评论 -
AttributeError: module ‘keras.optimizers‘ has no attribute ‘Adam‘
问题AttributeError: module ‘keras.optimizers’ has no attribute ‘Adam’解决:optimizers.Adam(lr=lr)改为tf.keras.optimizers.Adam(lr=lr)原创 2021-12-14 20:07:17 · 11559 阅读 · 0 评论 -
问题:Got an unexpected keyword argument ‘keep_dims‘
TimeDistributed(Lambda(lambda x: tf.reduce_max(x, axis=-2, keepdims=True)))(net)报错:reduce_max() Got an unexpected keyword argument ‘keep_dims’解决:查看函数实现,keep_dims 改为 keepdimsAttributeError: module ‘keras.optimizers’ has no attribute ‘Adam’optimizers.Ad原创 2021-12-14 20:03:09 · 3817 阅读 · 0 评论 -
model.fit()错误:ValueError: Layer “model“ expects 2 input(s), but it received 1 input tensors.
model.fit()错误:ValueError: Layer “model” expects 2 input(s), but it received 1 input tensors. Inputs received: [<tf.Tensor ‘IteratorGetNext:0’ shape=(8, 100, 236, 1) dtype=float32>]#beforemodel.fit([x_train, y_train], [y_train, x_train], batch_size原创 2021-12-09 16:41:43 · 5027 阅读 · 1 评论 -
ModuleNotFoundError: No module named ‘torch_sparse‘
https://github.com/rusty1s/pytorch_sparseYou can now install pytorch-sparse via Anaconda for all major OS/PyTorch/CUDA combinations ???? Given that you have pytorch >= 1.8.0 installed, simply runconda install pytorch-sparse -c pyg原创 2021-12-02 17:34:20 · 1728 阅读 · 0 评论 -
python对称矩阵下三角转数组表示
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar原创 2021-11-03 16:13:00 · 258 阅读 · 0 评论 -
Exception: Unexpected data type <class ‘numpy.bytes_‘>
booksheet.write(j,i,col) 报错Exception: Unexpected data type <class ‘numpy.bytes_’>改为:booksheet.write(j,i,str(col))原创 2021-09-27 10:52:54 · 752 阅读 · 0 评论 -
tensorflow版本问题 AttributeError: module ‘tensorflow‘ has no attribute ‘global_variables_initializer‘
import tensorflow as tf改为:import tensorflow.compat.v1 as tftf.disable_v2_behavior()原创 2021-09-27 10:51:29 · 405 阅读 · 0 评论 -
docopt.DocoptLanguageError: “usage:“ (case-insensitive) not found.
arguments = docopt(doc) 报错:docopt.DocoptLanguageError: “usage:” (case-insensitive) not found.在“”"“”"直接添加Usage:,Options:等说明。例:“”"Using multilayer perceptron (MLP) and ensemble learning to classify the ASD and TC based on single brain atlas.Usage:n原创 2021-09-27 10:29:28 · 375 阅读 · 0 评论 -
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb5 in position 2: invalid start byte
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb5 in position 2: invalid start byte解决:将pheno = pd.read_csv(pheno_path)改为pheno = pd.read_csv(pheno_path,encoding=‘ANSI’)原创 2021-09-16 17:12:23 · 1912 阅读 · 0 评论 -
File “h5py\h5f.pyx“, line 83, in h5py.h5f.open TypeError: expected bytes, str found
问题:File “h5py_objects.pyx”, line 54, in h5py._objects.with_phil.wrapperFile “h5py_objects.pyx”, line 55, in h5py._objects.with_phil.wrapperFile “h5py\h5f.pyx”, line 83, in h5py.h5f.openTypeError: expected bytes, str found解决:将h5py.h5f.open(filename, f原创 2021-09-14 11:08:16 · 1587 阅读 · 1 评论 -
Python数据正态拟合
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport matplotlib.mlab as mlabimport seaborn as sns#%matplotlib inlinesns.set(context='notebook',font='simhei',style='whiteg...原创 2019-12-13 16:02:53 · 7473 阅读 · 0 评论 -
Python随机生成数据并画散点图
import numpy as npimport pandas as pdimport matplotlib.pyplot as plt#%matplotlib inline#创建随机数据s = pd.DataFrame(np.random.randn(1000)+100, columns = ['value'])#生成1000个在100附件的数print(s.head())f...原创 2019-12-11 16:18:38 · 5667 阅读 · 0 评论 -
两张RGB合成pcl深度图像-ssd(平方差之和)块匹配算法
参考:https://github.com/IntelRealSense/librealsense/blob/development/doc/depth-from-stereo.mdStereoscopic VisionDepth from Stereo is a classic computer vision algorithm inspired by human binocula...原创 2019-10-18 19:44:16 · 1524 阅读 · 0 评论 -
ros_Python_Writing a Simple Publisher and Subscriber
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%291.创建工作空间和程序包roscd beginner_tutorials2.创建scripts文件夹mkdir scriptscd scripts3.Publisher Nodewget https://raw.gi原创 2016-08-22 19:29:23 · 1846 阅读 · 0 评论