当前位置:网站首页>Parse numpy.random.get_ State() and numpy.random.set_ state()
Parse numpy.random.get_ State() and numpy.random.set_ state()
2022-07-22 17:01:00 【Wanderer001】
- analysis numpy.random.get_state() and numpy.random.set_state()
- get_state(): It can be understood as setting state , Record the operation that the array is disrupted
- set_state(): receive get_state() The value returned , And do the same
- General combination random.shuffle() Function USES
- Scramble the two arrays of instance and label at the same time , But after the disruption , Instances and labels are still one-to-one correspondence
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 4 15:30:47 2018
@author: muli
"""
import numpy as np
#random.getstate()
# Returns the current internal state of the object capture generator . This object can be passed to setstate() To recover
#random.setstate(state)
# The state should have been obtained from previous calls getstate(),
# as well as setstate() Restore the generator getstate() Internal state when called .
a = np.arange(10)
print("a:")
print(a)
b=['A','B','C','D','E','F','G','H','I','J']
print("b:")
print(b)
print("----------------------------")
state=np.random.get_state()
np.random.shuffle(a)
print(a)
np.random.set_state(state)
np.random.shuffle(b)
print(b)
The result is :
a:
[0 1 2 3 4 5 6 7 8 9]
b:
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
----------------------------
[8 3 4 1 6 2 9 5 7 0]
['I', 'D', 'E', 'B', 'G', 'C', 'J', 'F', 'H', 'A']
边栏推荐
- Visual system design example (Halcon WinForm) -8. matching search
- Choerodon, an open source multi cloud application agile full link technology platform, released version 0.23
- Random forest learning notes
- 解析优化机器人课程体系与教学策略
- Understand recursion and iteration
- tf.get_default_graph
- tf.placeholder
- Binary tree OJ question, IO question
- 数据湖:数据湖技术架构演进
- tensorflow 神经网络实现鸢尾花分类
猜你喜欢
When the win10 system is turned on, the response is slower than usual. How to solve it by turning around and waiting for 1 minute?
Look at the steam education mode integrating mathematics teaching
How to solve the problem of win10? The app store cannot be opened, and the error code is 0x80131500
[open hand] hande enterprise PAAS platform hzero heavy open source!
HZERO企业级数字PaaS平台 (二)| 企业级权限体系
AlterNet Studio 8.1 Crack
Cartopy绘图入门指南
16_响应状态码
codeforce D2. RGB Substring (hard version) 滑動窗口
跨域问题(CORS)详细说明和解决
随机推荐
解析numpy.random.get_state()和numpy.random.set_state()
Use ffmpeg to push and pull streams
[MySQL] SQL tuning practice teaching
线程系列协程原理
Leetcode daily question 814. Binary tree pruning
Mecol Studio - harmonyos second assignment
tensorflow 神经网络实现鸢尾花分类
Repair version of Dynamic Video Wallpaper wechat applet source code download, supporting various types of traffic main revenue
UE4 植被工具的使用
ES6 arrow function
UE4 设置夜晚(根据DirectionalLight方向更新SkySphere)
UE4 用灰度图构建地形
Data Lake: evolution of data Lake Technology Architecture
汉得企业级数字化PaaS平台 HZERO 1.9.0 版本正式发布!
Four main steps of web application penetration testing
Yuanqi Digitalization: existing mode or open source innovation Lixia action
tf.compat
Li Kou daily question - day 41 -645. Wrong collection
TensorFlow 预测日销量
[論文翻譯] Generalized Radiograph Representation Learning via Cross-Supervision Between Images