当前位置:网站首页>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
边栏推荐
- [GO Language Basics] 1. Why do I want to learn Golang and the popularization of GO language entry
- 2022年SQL大厂高频实战面试题(详细解析)
- Seata exception: endpoint format should like ip:port
- 面试题 17.13. 恢复空格(字典树)
- [GLib] 什么是GType
- Mysql8.+学习笔记
- Introduction to Oracle Patch System and Opatch Tool
- JVM 垃圾回收 超详细学习笔记(二)
- 安装Nuxt.js时出现错误:TypeError:Cannot read property ‘eslint‘ of undefined
- MySQL 用户授权
猜你喜欢

mysql 中 in 的用法
![[GO Language Basics] 1. Why do I want to learn Golang and the popularization of GO language entry](/img/ac/80ab67505f7df52d92a206bc3dd50e.png)
[GO Language Basics] 1. Why do I want to learn Golang and the popularization of GO language entry
![[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及](/img/ac/80ab67505f7df52d92a206bc3dd50e.png)
[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及

Solve the problem that the local nacos is not configured but the localhost8848 connection exception always occurs

Redis学习

JVM 类加载机制 超详细学习笔记(三)

爬虫数据是如何收集和整理的?

MySQL(3)

Difference between cookie and session

Personal blog system (with source code)
随机推荐
MYSQL-InnoDB的线程模型
MySQL 数据库基础知识(系统化一篇入门)
Arrange numbers (DAY90) dfs
Personal blog system (with source code)
108. 将有序数组转换为二叉搜索树
Machine Learning - Gradient Descent Optimization - C language implementation
[详解C语言]一文带你玩转数组
留念 · 大学时代最后的系统设计图
php数组实现根据某个键值将相同键值合并生成新二维数组的方法
分布式事务之 Atomikos 原理和使用(一)
What is SOA (Service Oriented Architecture)?
Thymeleaf简介
It's time to have to learn English, give yourself multiple paths
St. Regis Takeaway Project: New dishes and dishes paged query
期末作业C#实现学生宿舍管理系统
2022年比若依更香的开源项目
CISP-PTE Zhenti Demonstration
机器学习—梯度下降Gradient Descent Optimization—c语言实现
手把手教你设计一个CSDN系统
[Koltin Flow (2)] The end operator of the Flow operator