random中的 get_state()和set_state()

numpy.random.get_state():保存状态,记录下数组被打乱的操作(数组如何被打乱的)
numpy.random.set_state():接收get_state()返回的值,按照get_state()打乱的方式对新数组进行同样的操作
可结合random.shuffle()函数使用,将实例与标签两个数组同时打乱,但打乱后,实例与标签任然是一一对应的关系
 

import numpy as np

train_data = [1, 2, 3, 4, 5, 6]
train_label = ['a', 'b', 'c', 'd', 'e', 'f']

#步骤1.记录当前打乱操作状态
cur_state=np.random.get_state()
# 步骤2.打乱序列a
np.random.shuffle(train_data)
# 步骤3.设定新的打乱操作状态
np.random.set_state(cur_state)
# 步骤4.打乱序列b
np.random.shuffle(train_label)
print(train_data)           #[6, 3, 1, 2, 5, 4]

print(train_label)          #['f', 'c', 'a', 'b', 'e', 'd']

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TWX PROXY v2.03 SOURCE RELEASE NOTES 12 March 2005 FOREWORD TWX Proxy began as a pet project of mine back in early 1999. Over a 6 year period, the project evolved from a simple VB "sendkeys" application into a fully featured telnet proxy server complete with its own flatfile database and powerful scripting engine. With frequent revisions, the project has stayed quite lean considering its feature set (some 23000 lines of core code). While I originally started the project in an effort to improve my own play of Trade Wars 2002, it rapidly gained momentum and demand for it grew. By 2002, it was almost impossible to compete in TW2002 tournament play without prior programming experience or the use of TWX Proxy. The revolutionary proxy design that was the major selling point of the program allowed users to put together the best features of other helpers with many of the freeware (and commercial) scripts that became available for it. While many other helpers have a far simpler and easier to use interface, TWX Proxy made its dent through reliability, flexibility, and scriptability. The program has been through many major revisions, starting from the low profile 1.1 and finishing with the largely refactored 2.03. 1.06b saw the introduction of the Pack2 scripts - a commercial script library that had a massive impact on the way TW2002 is played. The largest revision (2.00) saw a near complete rewrite of the source code to include a much more efficient script compiler/interpreter that allowed far more modularity in script construction. The 2.00 release was a major breakthrough in scripting capability featuring scripts that were capable of independently roaming a random universe while trading, creating, upgrading and colonising planets without any user intervention required. The 2.03 release was mostly a cleanup effort to try and root out some of the last remaining corners of legacy code and pound the program into a more modular layout. While still far from perfect, the code is finally in a state where I no longer feel extremely embarrassed putting it out where others can get to it. It is my hope that by releasing this source under the GPL, TWX Proxy will continue to grow as part of a community effort and will continue to help level the TW playing field between the general population and the programmers that actively dominate the game. I would like to offer my heartfelt gratitude to the many testers, scripters and users that have all made such an effort to make TWX Proxy a success. Without you, this project simply would not exist.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值