当前位置:网站首页>One hot code
One hot code
2022-07-03 11:14:00 【vanguard】
Fever alone /one-hot It is used to represent a special byte or vector in digital circuits and machine learning ,
Intuitively speaking, there are as many bits as there are states , And only one bit is 1, For all other 0 A code system of .
Only one bit of this byte or vector is allowed to be 1, All other bits must be 0.
It is called the sole heat because there can only be one 1, If the opposite is true , only one 0, Others are 1, Is called alone cold (one-cold).
In statistics , Dummy variables represent similar concepts .
Usually , In the communication network protocol stack , Use 8-bit or 16 bit state unique hot code , And the system occupies one of the status codes , The rest can be used by users .
import numpy as np
wide = 10
test = np.random.randint(wide,size=5)
print(test)
# raw
def one_hot(num,wide):
res = np.zeros(wide)
res[num] = 1
return res
print(np.array([one_hot(i,wide) for i in test]))
# batch
def one_hots(narr,wide):
res = np.zeros((narr.size,wide))
row = np.arange(narr.size)
res[row, narr] = 1
return res
print(one_hots(test,wide))
# multi-hot
test = np.array([[1,2,3,4,5],[7,8,9,0,1]])
print(np.array([one_hots(i,wide).sum(axis=0) for i in test]))
# tensorflow
import tensorflow as tf
print(tf.keras.utils.to_categorical(test,num_classes=(wide)))
# ...
from sklearn.preprocessing import LabelBinarizer
print(LabelBinarizer().fit(np.arange(wide)).transform(test))
# OneHotEncoder ...
# pandas
# import pandas as pd
# print(pd.get_dummies(test,wide))...
边栏推荐
- 8年测试总监的行业思考,看完后测试思维认知更深刻
- AIDL
- Commonly used discrete random distribution
- Qt:qss custom qradiobutton instance
- What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
- QT: QSS custom qtreeview instance
- 行业唯一!法大大电子合同上榜36氪硬核科技企业
- 在腾讯云容器服务Node上执行 kubectl
- Basic usage of sqlmap
- Hard goods | write all the codes as soon as you change the test steps? Why not try yaml to realize data-driven?
猜你喜欢

redis那些事儿
![[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder](/img/1f/729594930c7c97d3e731987f4c3645.png)
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder

软件测试工程师的5年之痒,讲述两年突破瓶颈经验

11. Provider service registration of Nacos service registration source code analysis

历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料

After 8 years of industry thinking, the test director has a deeper understanding of test thinking

嵌入式软件测试怎么实现自动化测试?

在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获

公司测试部门来了个00后卷王之王,老油条感叹真干不过,但是...

The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
随机推荐
Error installing the specified version of pilot
Qt:qss custom qmenubar instance
做软件测试三年,薪资不到20K,今天,我提出了辞职…
Basic usage of sqlmap
ByteDance layoffs, test engineers were almost destroyed: how terrible is the routine behind the recruitment of large factories?
What experience is there only one test in the company? Listen to what they say
Clion debug
Inexplicable problems in the nesting of constraintlayout and relativelayout
Summary of the history of Mathematics
A simple method of adding dividing lines in recyclerview
I have been doing software testing for three years, and my salary is less than 20K. Today, I put forward my resignation
17K薪资要什么水平?来看看95后测试工程师的面试全过程…
如何:配置 ClickOnce 信任提示行为
我对测试工作的一些认识(资深测试人员总结)
Kotlin's use of the no Arg compiler plug-in in gradle
12. Nacos server service registration of source code analysis of Nacos service registration
Solution: jupyter notebook does not pop up the default browser
使用onvif协议操作设备
AMS series - application startup process
Qt:qss custom qspinbox instance