Python系列
浅蓝的风
一场简单的旅行
展开
-
Pytorch中的矩阵相乘用法
案例:# 矩阵相乘有以下五种方式a = torch.ones(2,1)b = torch.ones(1,2)c = torch.matmul(a, b)print(c)print(torch.mm(a, b))print(a @ b)print(a.matmul(b))print(a.mm(b))"""tensor([[1., 1.], [1., 1.]])tensor([[1., 1.], [1., 1.]])tensor([[1., 1.]原创 2021-08-23 21:02:38 · 766 阅读 · 0 评论 -
tf.pad()函数的使用讲解
这个函数主要是对数据矩阵边缘进行填充import tensorflow as tfimport numpy as nparr = np.array(np.arange(1, 10)).reshape([3, 3])print(arr)b = tf.pad(arr, paddings=[[0, 1], [1, 2]])sess = tf.InteractiveSession()print(b.eval())"""[[1 2 3] [4 5 6] [7 8 9]]------原创 2021-08-20 17:40:50 · 512 阅读 · 0 评论 -
numpy中np.inf函数的用法讲解
np.inf 表示+∞,是没有确切的数值的,类型为浮点型import numpy as np"""np.inf 表示+∞,是没有确切的数值的,类型为浮点型"""# a值表示+∞a = np.inf# b的值无论我们设置的有多大都会小于a值b = (10 ** 10) ** 10000print(a)print(type(a)) # <class 'float'>print(b)if a > b: print('a > b')else:.原创 2021-08-20 15:02:22 · 27704 阅读 · 0 评论 -
TensorFlow中tf.gather()函数的使用讲解
下面我们直接看使用方法和功能介绍:import tensorflow as tfimport numpy as np"""1. 该函数的参数讲解: tf.gather( params, 传入的tensor indices, 指定的索引 validate_indices=None, 不重要 name=None, 命名 a原创 2021-08-19 11:35:32 · 3758 阅读 · 3 评论 -
tensorflow中tf.ones_like()和tf.zeros_like() 函数使用讲解
该函数的使用如下,其中包含该函数的参数和功能讲解:import tensorflow as tf"""1. 该函数的参数讲解: tf.ones_like(tensor, 需要传入的tensor dtype='', 返回的数据类型 name='') 命名2. 功能: 根据传入的tensor的形状创建一个同形状,值为1的tensor"""p1 = tf.placeholder(shape=[2], dt原创 2021-08-19 11:09:29 · 1143 阅读 · 0 评论 -
YOLOv3中使用kmeans算法生成anchors
我们直接看代码逻辑:# coding: utf-8# This script is modified from https://github.com/lars76/kmeans-anchor-boxesfrom __future__ import division, print_functionimport numpy as npdef iou(box, clusters): """ Calculates the Intersection over Union (IoU)原创 2021-08-18 16:16:19 · 1028 阅读 · 0 评论 -
Celery框架安装及使用
一、环境配置 1.安装:python3.7.2(这里我是使用此版本做示例)2. vnc安装(用于可视化监控):apt install xfce4 xfce4-goodies tightvncserver3. 主要依赖:celery==4.2.1、APScheduler==3.6.3、elasticsearch==7.8.0、rq==1.4.3、redis==3.2.0二、配置Celery及关联业务任务 1.celery配置:a...原创 2021-06-24 15:27:17 · 685 阅读 · 0 评论