当前位置:网站首页>np.where()用法
np.where()用法
2022-07-30 05:38:00 【向大厂出发】
np.where有两种用法
1、np.where(condition,x,y) 当where内有三个参数时,第一个参数表示条件,当条件成立时where方法返回x,当条件不成立时where返回y。
2、np.where(condition) 当where内只有一个参数时,那个参数表示条件,当条件成立时,where返回的是每个符合condition条件元素的坐标,返回的是以元组的形式。
代码示例:
#用法一
#当self.net_input(X)返回的值大于等于0.0时,where返回1,否则返回0
np.where(self.net_input(X) >= 0.0, 1, 0)#用法二
import numpy as np
a = np.array([2, 4, 6, 8, 10])
# 只有一个参数表示条件的时候
print(np.where(a > 5))
# out
(array([2, 3, 4], dtype=int64),)
参考:https://blog.csdn.net/island1995/article/details/90200151
边栏推荐
- The difference between asyncawait and promise
- 429. N 叉树的层序遍历(两种解法)
- It is enough for MySQL to have this article (37k words, just like Bojun!!!)
- MySQL 灵魂 16 问,你能撑到第几问?
- G Bus Count (Google Kickstart2014 Round D Problem B) (DAY 89)
- Different usage scenarios of subqueries as retrieval tables and the question of whether to add aliases
- 75. 颜色分类
- Introduction to Oracle Patch System and Opatch Tool
- 坠落的蚂蚁(北京大学考研机试题)
- 腾讯面试居然跟我扯了半小时的CountDownLatch
猜你喜欢

Error: npm ERR code EPERM

net start mysql MySQL 服务正在启动 . MySQL 服务无法启动。 服务没有报告任何错误。

JVM之GC 调优基础知识(一)

2022 Pengcheng Cup web

How is crawler data collected and organized?

Navicat new database

cnpm installation steps

mysql 时间字段默认设置为当前时间

Navicat cannot connect to mysql super detailed processing method

navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)
随机推荐
[Image processing] Image skeleton extraction based on central axis transformation with matlab code
MySQL的 DDL和DML和DQL的基本语法
爬虫数据是如何收集和整理的?
[Mysql] CONVERT函数
839. 模拟堆
JVM 垃圾回收 超详细学习笔记(二)
手把手教你彻底卸载MySQL
ClickHouse data insert, update and delete operations SQL
2022 SQL big factory high-frequency practical interview questions (detailed analysis)
Difference between cookie and session
MySQL(4)
navicat新建数据库
postman 请求 post 调用 传 复合 json数据
【Koltin Flow(二)】Flow操作符之末端操作符
瑞吉外卖项目:新增菜品与菜品分页查询
成绩排序(华中科技大学考研机试题)(DAY 87)
破纪录者(Google Kickstart2020 Round D Problem A)
MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及
MySQL 灵魂 16 问,你能撑到第几问?