"""
drop out隨機丟棄神經元
"""
import torch
def dropout_layer(X, dropout):
assert 0 <= dropout <= 1
# 在本情況中,所有元素都被丟棄
if dropout == 1:
return torch.zeros_like(X)
# 在本情況中,所有元素都被保留
if dropout == 0:
return X
mask = (torch.rand(X.shape) > dropout).float()
return mask * X / (1.0 - dropout)
X = torch.arange(16, dtype=torch.float32).reshape((2, 8))
print(X)
print(dropout_layer(X, 0.))
print(dropout_layer(X, 0.5))
print(dropout_layer(X, 1.))
torch--drop out
相關文章
- Kotlin 1.2.50 is out!Kotlin
- OOM(Out Of Memory)OOM
- SQL not exist out joinSQL
- Resource is out of sync with the file system
- 塊清除(block clean out)BloC
- 【PAT】1006 Sign In and Sign Out
- Tape-out Checklist FormORM
- B. Two Out of Three
- 再不用ContraintLayout就out啦AI
- Eclipse:Resource is out of sync with the file systemEclipse
- 好書推薦《Out of the Maze》
- Look what I found out.
- PTA-1006—— Sign In and Sign Out
- (轉貼)Out of Memory: Killed process
- OOM(Out Of Memory)是什麼?OOM
- sky-take-out chapter 1APT
- Black Out for mac (影像模糊工具)Mac
- Kotlin 泛型中的 in 和 outKotlin泛型
- CSS :out-of-range 選擇器CSS
- out,ref,params引數傳遞
- [Clickhouse] Clickhouse 報SQLException : Read timed outSQLException
- Python3:EOFError: Ran out of inputPythonError
- JAVA IPMI Command time out 解決方法Java
- 只知道ajax?你已經out了
- [深度學習]丟棄法(drop out)深度學習
- 完蛋!我被 Out of Memory 包圍了!
- Tomcat關閉日誌catalina.outTomcat
- JSP九大內建物件 out request responseJS物件
- Analyzing and Reproducing the EOS Out-of-Bound Write Vulnerability in nodeos
- 擴充套件節能器:Lights Out for Mac套件Mac
- PostgreSQL DBA(95) - PG 12 Partition(out of shared memory)SQL
- 【ERROR】ORA-27102: out of memory 解決方法Error
- 再不遷移到Material Design Components 就out啦Material Design
- Caused by: java.lang.IllegalArgumentException: port out of range:-1JavaException
- 使用PowerShell Out-GridView作為GUI替代ViewGUI
- 關於System.out.println的意義
- 使用Fan-Out模式併發處理模式
- pip 下載報"connection to pypi.org time out"