ICode9

精准搜索请尝试: 精确搜索
  • NumPy数组的创建2022-07-30 19:01:18

    一、NumPy 创建数组 ndarray 数组除了可以使用底层 ndarray 构造器来创建外,也可以通过以下几种方式来创建。 1.numpy.empty numpy.empty 方法用来创建一个指定形状(shape)、数据类型(dtype)且未初始化的数组: numpy.empty(shape, dtype = float, order = 'C')   shape 数组形状

  • Numpy之Ndarray对象、数据类型和属性2022-07-29 22:34:53

    一、NumPy Ndarray 对象 NumPy 最重要的一个特点是其 N 维数组对象 ndarray,它是一系列同类型数据的集合,以 0 下标为开始进行集合中元素的索引。 ndarray 对象是用于存放同类型元素的多维数组。 ndarray 中的每个元素在内存中都有相同存储大小的区域。 ndarray 内部由以下内容组成:

  • numpy 数据类型转化2022-07-22 19:44:30

    查看数据类型:dtype 例子1: In[1]: a = np.arange(5) In[2]: a.dtype Out[1]: dtype('int32') 例子2: In[1]: b = np.array([1.00, 2.00 ,3.00 ,4.00 ], dtype=np.float64) In[2]: b.dtype Out[1]: dtype('float64') 数据转换:astype 例子1: In[1]: a = a.astype(np.fl

  • pandas.core.window.rolling.Rolling.mean2022-07-19 16:03:40

    Rolling.mean(*args, engine=None, engine_kwargs=None, **kwargs) Calculate the rolling mean.计算滚动窗口的平均值 examples The below examples will show rolling mean calculations with window sizes of two and three, respectively. s = pd.Series([1, 2, 3, 4]) s.

  • pandas :按另一列的值移动一列2022-07-07 19:31:07

    我们可以使用 numba解决方案: from numba import jit @jit def dyn_shift(s, step): assert len(s) == len(step), "[s] and [step] should have the same length" assert isinstance(s, np.ndarray), "[s] should have [numpy.ndarray] dtype" assert

  • [TensorFlow]01 张量2022-06-28 16:05:35

    张量 01 张量的形状 import tensorflow as tf a=tf.constant(4) # 标量a print(a) tf.Tensor(4, shape=(), dtype=int32) b=tf.constant([2.0,3.0,4]) # 向量 print(b) tf.Tensor([2. 3. 4.], shape=(3,), dtype=float32) c=tf.constant([[1,2],[3,4]]) # 2个轴,类比与单通道

  • nn.CrossEntropyLoss()使用是label参数的注意点2022-06-27 02:00:20

    遇到个离谱的事情,自定义数据集跑cross entropy loss的时候, loss1 = w_loss.loss(log_ps1, source_batch_labels) loss1.backward() backward()这里总是报错,搞了半天最后发现是数据集设定的时候,给labels是int32,但是实际上得设置成int64 # toy_source数据类型转化 source_

  • python学习杂记——生成序列的方法range()、numpy.arange()、numpy.linspace()和numpy.logspace()2022-05-26 22:33:30

    摘自菜鸟教程 1 range() range(stop) range(start, stop[, step]) 参数说明: start: 计数从 start 开始。默认是从 0 开始。例如range(5)等价于range(0, 5); stop: 计数到 stop 结束,但不包括 stop。例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5 step:步长,默认为1。例如:range(5)等价于 range(0, 5)

  • to numpy() and to torch()2022-04-27 12:34:40

    def to_numpy(self) -> 'Batch': """Change all torch.Tensor to numpy.ndarray in-place.""" for k, v in self.items(): if isinstance(v, torch.Tensor): self[k] = v.detach().cpu().numpy() retu

  • tensorflow的读书笔记2022-04-25 00:35:23

    #定义一个2行3列全为0的矩阵 tensor1 = tf.zeros([2,3]) print(tensor1)"""运行结果:tf.Tensor([[0. 0. 0.][0. 0. 0.]], shape=(2, 3), dtype=float32)"""#定义一个2行2列全为1的矩阵 ones_tsr = tf.ones([2, 2])print(ones_tsr)"""运行结果:  tf.Tensor( [[1

  • 深度学习笔记2022-04-25 00:02:36

    tensorflow中的tensor就是张量,是多维数组(多维列表),用阶来表示张量的维数,判断张量是几阶的可以看有几个方括号 import tensorflow as tf a=tf.constant([1,5],dtype=tf.int64) #直接打印a,会输出a的所有信息 print(a) #打印a的数据类型 print(a.dtype) #打印a的形状 print(a.shap

  • Tensflow学习笔记2022-04-24 22:33:00

    import tensorflow as tf sess=tf.compat.v1.Session()a=tf.constant(32) #创建常量b=tf.constant(10) #创建常量#加法a+b+bd=tf.add_n([a,b,b])print(d) 运行结果: Tensor("AddN_3:0", shape=(), dtype=int32) #减法a-be=tf.subtract(a,b)print(b) 运行结果: Tensor("Const_17:0&q

  • Numpy的一些操作2022-04-15 19:01:29

    1、什么是Numpy 简单来说: Numpy(Numerical Python)是一个开源的Python科学计算库,用于快速处理任意维度的数组。 Numpy支持常见的数组和矩阵操作。对于同样的数值计算任务,使用Numpy比直接使用Python要简洁的多。 Numpy使用ndarray对象来处理多维数组,该对象是一个快速而灵活的大数据

  • 2-1张量数据结构——eat_tensorflow2_in_30_days2022-04-03 17:33:44

    程序=数据结构+算法 TensorFlow程序=张量数据结构+计算图算法语言 张量和计算图是TensorFlow的核心概念 TensorFlow的基本数据结构是张量Tensor。张量即多维数组。TensorFlow的张量和NumPy中的ndarray很类似 从行为特性来看,有两种类型的张量,常量constant和变量Variable 常量的值

  • pytorch基本语法2022-03-26 17:00:08

    pytorch安装 bing官网 找对应版本下载 记住一点:-c pytorch不要加上,否则下载速度巨慢 pytorch的基本语法 tensor张量 基本概念 标量:0维张量 矢量:一维张量 矩阵:二维张量 矩阵数组:三维张量 tensor()是一个函数 代码演示: tensor = torch.arange(2,14,2):不用手打,创建一维张量,取不到14

  • DL——numpy常用方法2022-03-25 21:34:40

    引入numpy科学计算库: import numpy as np   --->创建元素均为零的矩阵,大小为shape,元素类型dtype: np.zeros(shape, dtype) --->创建等差数组,返回一维的数组(可以用reshape将其变为矩阵更好处理一些) np.arange([start=0],stop,[step=1],[dtype=np.int32]) --->创建x*x的对角矩阵: np.

  • 使用python发生此类错误 ValueError: endog must be in the unit interval.2022-02-28 11:33:42

    from functools import reduce import pandas as pd import statsmodels.api as sm import numpy as np from scipy.optimize import minimize df = pd.read_csv("pheno.asd", sep="\s+", header=0) gmat = np.loadtxt("test.agrm.mat_fmt")

  • tensorflow安装无法导入2022-02-24 10:00:08

      1.查看本地安装版本 pip list 记住自己的版本,方便第二步进行卸载 2.卸载本地版本 pip uninstall tensorflow==2.1.0     #我的版本是2.1.0  3.查看是否卸载 pip list  4.安装1.12.0版本 pip install tensorflow==1.12.0  -i http://pypi.douban.com/simple --trusted-

  • python中如何找出numpy array数组的最值及其索引?2022-02-22 17:04:21

    转自:微点阅读  https://www.weidianyuedu.com 在list列表中,max(list)可以得到list的最大值,list.index(max(list))可以得到最大值对应的索引 但在numpy中的array没有index方法,取而代之的是where,其又是list没有的 首先我们可以得到array在全局和每行每列的最大值(最小值同理) >

  • Lesson3——Pandas Series结构2022-02-05 23:33:03

    1 什么是Series结构?   Series 结构,也称 Series 序列,是 Pandas 常用的数据结构之一,它是一种类似于一维数组的结构,由一组数据值(value)和一组标签组成,其中标签与数据值之间是一一对应的关系。   Series 可以保存任何数据类型,比如整数、字符串、浮点数、Python 对象等,它的标签默认

  • mumpy常用函数2022-02-02 16:01:13

    numpy.array(list(1,2,3,4)) #将一个list类型/tupe类型数据转换为一个array数组对象 #默认所有的数据类型都是相同,若传进来的参数类型不同,则遵循以下优先级: str > float > int ndarray对象.dtype #查看array对象中的数据类型 data = numpy.array(1,2,"1") print(dat

  • The default dtype for empty Series will be ‘object‘ instead of ‘float64‘ in a future version2022-02-01 19:33:47

    警告提示: DeprecationWarning: The default dtype for empty Series will be ‘object’ instead of ‘float64’ in a future version warning 解决方法: 将 pd.Series([])改为pd.Series([], dtype=pd.StringDtype())

  • Python学习笔记——Numpy的初步学习2022-01-27 00:03:41

    目录 1.Numpy介绍 2.数组 2.1创建数组 2.2数组的属性  2.3创建特殊的数组 2.4数组切片操作  2.4.1——一维数组的切片 2.4.3——二维数组的切片 2.4.4——三维数组的切片 2.5——reshape与resize    3.数组运算 4.个人总结  hello^-^,感谢各位的来访,祝南方的小伙伴小年快乐

  • pandas库2022-01-25 18:00:36

    pandas是python第三方库,提供高性能易用数据类型和分析工具。 pandas基于numpy实现,常与numpy和matplotlib一同使用 更多学习,请参考pandas中文网:https://www.pypandas.cn/ 目录 1.Series 2.DataFrame 1.Series Series是一种类似于一维数组的对象,它由一维数组(各种numpy数据类型)

  • Pandas通用函数和运算2022-01-24 16:35:14

    Pandas继承了Numpy的运算功能,可以快速对每个元素进行运算,即包括基本运算(加减乘除等),也包括复杂运算(三角函数、指数函数和对数函数等)。 通用函数使用 apply和applymap apply(func,axis=0,broadcast=None,raw=False,reduce=None,result_type=None,args=(),**kwds,) applymap(func)

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有