当前位置: 首页 > news >正文

JAX study notes[7]

文章目录

  • jax.numpy
    • jax.numpy.linspace
    • jax.numpy.arange
  • references

jax.numpy

jax.numpy.linspace

jax.numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None)

return a set of numbers separated with the fixed interval evenly.

import jax
import jax.numpy as jnp
print(jnp.linspace(11,55,5))
[11. 22. 33. 44. 55.]
import jax
import jax.numpy as jnp
print(jnp.linspace(11,55,5,retstep=True))
(Array([11., 22., 33., 44., 55.], dtype=float32), Array(11., dtype=float32))

the function can also use for generating multiple dimensions array.

import jax
import jax.numpy as jnp
print(jnp.linspace(jnp.array([1,11]),jnp.array([5,55]),5))
[[ 1. 11.][ 2. 22.][ 3. 33.][ 4. 44.][ 5. 55.]]

jax.numpy.arange

the function make also a sequence consisted of number and they are separated by equal interval.the function is similar as jax.numpy.linspace.but the important difference is that jax.numpy.arange runing depend on the step which means interval and the jax.numpy.linspace is applied with the argument num which represents the number of numbers.

jax.numpy.arange(start, stop=None, step=None, dtype=None, *, device=None)
[11 22 33 44]

there are a difference which is easily ignored usually that the stop at jax.numpy.arange means the end but excusive itself.by the way, jax.numpy.arange’s arguments must be scalars.
the following code will get a error when it runing.

print(jnp.arange(jnp.array([1,11]),jnp.array([5,55]),11))

references

https://docs.jax.dev/

http://www.lqws.cn/news/549055.html

相关文章:

  • uniapp消息推送
  • Springboot中常用的注解(分层整理)
  • Redis主从复制原理
  • CI/CD的常规设置及核心原理
  • 【大数据】大数据产品基础篇
  • OpenCV图像添加水印
  • Java底层原理:深入理解JVM类加载机制与反射机制
  • nginx:配置反向代理后不生效
  • 智能实验室革命:Deepoc大模型驱动全自动化科研新生态
  • could not import google.golang.org/protobuf/proto
  • 前沿融合:机器学习如何重塑智能水泥基复合材料研发范式
  • 学习设计模式《十五》——模板方法模式
  • 多张图片生成PDF每张图片生成pdf的一页
  • Windows Server 2019 查询远程登录源 IP 地址(含 RDP 和网络登录)
  • 论云原生架构及应用
  • AcWing--数据结构(二)
  • clion配置旧的C项目为CMake项目工程
  • 生成树基础实验
  • 【C++】atoi和std::stoi
  • 本年度TOP5服装收银系统对比推荐
  • HTTPS hostname wrong: should be <xxx>错误解决
  • .小故事.
  • 基于DeepSeek搭建Dify智能助手国产化架构运行arm64
  • 【LeetCode】滑动窗口相关算法题
  • leetcode.2014 重复k次的最长子序列
  • Deformable Transformer 详解
  • 本地缓存Caffeine详解(含与Spring Cache集成)
  • Java 工程智能化升级:飞算科技重构软件开发的技术范式
  • 电子电气架构 --- 涵盖“诊断与 ECU 平台”领域特有项目要求(上)
  • go写前端打包的自动化工具