查看“︁独热”︁的源代码
←
独热
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{NoteTA |G1=IT }} {| class="wikitable" border="1" align="right" |- ! [[二進制]] !![[格雷碼]]!! 独热码 |- | 000 || 000 || 00000001 |- | 001 || 001 || 00000010 |- | 010 || 011 || 00000100 |- | 011 || 010 || 00001000 |- | 100 || 110 || 00010000 |- | 101 || 111 || 00100000 |- | 110 || 101 || 01000000 |- | 111 || 100 || 10000000 |} '''独热'''<ref>{{cite journal|last1=梁|first1=杰|last2=陈|first2=嘉豪|last3=张|first3=雪芹|last4=周|first4=悦|last5=林|first5=家骏|title=基于独热编码和卷积神经网络的异常检测|journal=清华大学学报 (自然科学版)|date=2019|volume=59|issue=07|pages=523-529|doi=10.16511/j.cnki.qhdxxb.2018.25.061|url=https://kns.cnki.net/kcms/detail/detail.aspx?FileName=QHXB201907004&DbName=DKFX2019|accessdate=2022-05-22|archive-date=2022-05-31|archive-url=https://web.archive.org/web/20220531173943/https://kns.cnki.net/kcms/detail/detail.aspx?FileName=QHXB201907004&DbName=DKFX2019}}</ref>({{lang-en|One-hot}}<!-- 中英文都常用-->)在[[數位電路]]和[[機器學習]]中被用來表示一種特殊的[[位元]]組或[[向量空間|向量]],該位元組或向量裏僅容許其中一位爲1,其他位都必須爲0<ref>{{cite book|last=Harris|first=David and Harris, Sarah|title=Digital design and computer architecture|publisher=Morgan Kaufmann|location=San Francisco, Calif.|isbn=978-0-12-394424-5|edition=2nd|page=p.129|year=|pages=}}</ref>。其被稱爲独热因爲其中只能有一個1,若情況相反,只有一個0,其餘爲1,則稱爲'''独冷'''(One-cold)<ref>{{cite journal|title=Event Extraction Based on Deep Learning in Food Hazard Arabic Texts|arxiv=2008.05014}}</ref>。在統計學中,[[虚拟变量]]代表了類似的概念。 == 應用 == === 有限狀態機 === 独热碼常常被用來表示一個[[有限狀態機]]的{{Translink|en|State (computer science)|狀態 (計算機科學)|狀態}}。如果使用[[二進制]]或[[格雷碼]]來代表狀態,則需要用到[[解碼器]]才能得知該碼代表的狀態。使用独热码來代表狀態的話,則不需要解碼器,因爲若第<math>n</math>個位元爲1,就代表機器目前在第<math>n</math>個狀態。 一個有限狀態機的例子是由15個狀態構成的{{Translink|en|Ring counter|環狀計數器|環狀計數器}}。使用独热編碼來實現此狀態機的話,可以將15個[[正反器]]串聯在一起,每個正反器的Q輸出接到下一個正反器的D輸入,而第一個正反器的D輸入則是接到第15個的Q輸出,形成一個環狀。第一個正反器代表機器的第一個狀態,第二個正反器代表第二個狀態,依此類推。當機器被歸零重設時,第一個正反器的值爲1,其餘爲0。當一個[[信号边缘|時脈邊緣]]抵達正反器時,會將1推進到下一個正反器。依照這種方式,1可一步步推進到第15個正反器,亦即第15個狀態,再之後則重新回到第一個狀態。 {{Translink|en|Address decoder|位址解碼器|位址解碼器}}可以將二進制或格雷碼轉換成独热码,而[[優先編碼器]]則是作用相反。 ==== 與其他編碼的差異 ==== ===== 優點 ===== * 決定狀態機目前狀態的時間成本低,因爲讀取一個正反器的時間成本固定。 * 改變機器的狀態所需時間成本也是固定,因爲每次只需要改變兩個正反器的值。 * 設計及設計變更容易。 * 容易偵測出非法狀態。 * 可以有效率地使用[[現場可程式化邏輯門陣列|FPGA]]的大量正反器<ref name=":0">{{Cite book|title=HDL Synthesis for FPGAs Design Guide|last=Xilinx Inc.|first=|publisher=|year=1995|isbn=|location=|pages=|chapter=Appendix A Accelerate FPGA Macros with One-Hot Approach|language=en|url=https://www.xilinx.com/txpatches/pub/documentation/xactstep6/hdlsynth.pdf|format=PDF|access-date=2019-09-09|archive-date=2020-05-15|archive-url=https://web.archive.org/web/20200515223916/https://www.xilinx.com/txpatches/pub/documentation/xactstep6/hdlsynth.pdf|dead-url=no}}</ref>。 相較於其他編碼,使用独热码來實現狀態機通常可以達到更高的[[時脈頻率]]<ref name=":0" /><ref>{{Cite book|title=HDL Synthesis for FPGAs Design Guide|last=Xilinx Inc|first=|publisher=|year=1995|isbn=|location=|pages=|url=https://www.xilinx.com/txpatches/pub/documentation/xactstep6/hdlsynth.pdf|chapter=Section 3-13. Encoding State Machines|format=PDF|language=en|access-date=2019-09-09|archive-date=2020-05-15|archive-url=https://web.archive.org/web/20200515223916/https://www.xilinx.com/txpatches/pub/documentation/xactstep6/hdlsynth.pdf|dead-url=no}}</ref>。 ===== 缺點 ===== * 比起其他編碼,需要更多的正反器,使得其在[[可程式化陣列邏輯|PAL]]裝置上不切實際。 * 會有很多非法狀態存在<ref>{{Cite book|title=Real Chip Design and Verification Using Verilog and VHDL|last=Cohen|first=Ben|publisher=VhdlCohen Publishing|year=2002|isbn=0-9705394-2-8|location=Palos Verdes Peninsula, CA, US|pages=p.48}}</ref>。這是由於<math>N</math>個正反器構成的[[计数器|計數器]]總共有<math>2^N</math>個狀態(每個正反器可以是0或1,所以總共<math>2^N</math>種可能狀態),但是合法狀態卻只有<math>N</math>個(即同一時間只允許一個正反器是1,其他必須爲0),所以總共會有<math>2^N-N</math>個可能的非法狀態。 === 自然語言處理 === 在[[自然語言處理]]中,若有個字典或字庫裏有<math>N</math>個單字,則每個單字可以被一個<math>N</math>維的独热向量代表<ref>{{cite conference |last1=Arnaud |first1=Émilien |last2=Elbattah |first2=Mahmoud |last3=Gignon |first3=Maxime |last4=Dequen |first4=Gilles |date=2021-08 |pages=548–553 |title=NLP-Based Prediction of Medical Specialties at Hospital Admission Using Triage Notes |url=https://ieeexplore.ieee.org/abstract/document/9565791 |conference=2021 IEEE 9th International Conference on Healthcare Informatics (ICHI) |access-date=2022-05-22 |location=[[維多利亞 (不列顛哥倫比亞)|Victoria, British Columbia]] |doi=10.1109/ICHI52183.2021.00103 |archive-date=2022-06-04 |archive-url=https://web.archive.org/web/20220604075741/https://ieeexplore.ieee.org/abstract/document/9565791 }}</ref>。譬如若字庫裏僅有apple(蘋果)、banana(香蕉)以及pineapple(鳳梨)這三個單字,則他們各自的独热向量可以爲: <math>\begin{array}{ll} apple &=[1\ 0\ 0] \\ banana &=[0\ 1\ 0] \\ pineapple &=[0\ 0\ 1] \end{array}</math> 由於電腦無法理解非數字類的數據,独热編碼可以將類別性數據轉換成統一的數字格式,方便機器學習的演算法進行處理及計算。而轉換成固定維度的向量則方便機器學習演算法進行線性代數上的計算。另外由於一個独热向量中,絕大部分的數字都是0,所以若使用[[稀疏矩阵|稀疏矩陣]]的資料結構,則可以節省電腦記憶體的使用量。 == 參見 == * [[触发器#D触发器|D正反器]] * [[一进制]] * [[唯一量化]] * [[异或门]] * [[译码器]] == 參考文獻 == {{Reflist}} [[Category:数字电路]] [[Category:一]]
该页面使用的模板:
Template:Cite book
(
查看源代码
)
Template:Cite conference
(
查看源代码
)
Template:Cite journal
(
查看源代码
)
Template:Lang-en
(
查看源代码
)
Template:NoteTA
(
查看源代码
)
Template:Reflist
(
查看源代码
)
Template:Translink
(
查看源代码
)
返回
独热
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息