"""
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
相關文章
- OOM(Out Of Memory)OOM
- Out With the Old and in With the New
- java out of memoryJava
- out of springSpring
- OCP(11g)-----> oracle First In First Out (FIFO)/Last In First OutOracleAST
- SQL not exist out joinSQL
- OOM--OUT OF MEMORYOOM
- Kotlin 1.2.50 is out!Kotlin
- Resource is out of sync with the file system
- ref和out區別
- B. Two Out of Three
- Tape-out Checklist FormORM
- fluentd out_forward翻譯Forward
- 內建物件out和PrintWriter物件
- ref和out的區別
- An out of memory error has occurred.Error
- Why MongoDB Never Worked Out at EtsyMongoDB
- 好書推薦《Out of the Maze》
- sky-take-out chapter 1APT
- OOM(Out Of Memory)是什麼?OOM
- CSS :out-of-range 選擇器CSS
- Eclipse:Resource is out of sync with the file systemEclipse
- Black Out for mac (影像模糊工具)Mac
- out,ref,params引數傳遞
- 還不會 PostCSS?你 OUT 啦!CSS
- Kotlin 泛型中的 in 和 outKotlin泛型
- Python3:EOFError: Ran out of inputPythonError
- 使用in out引數模式的過程模式
- 使用out引數模式的過程模式
- squid!Your cache is running out of fileUI
- Find Out Top Ten Largest Files in LinuxLinux
- Oracle (block clean out) oracle的塊清除OracleBloC
- nginx “504 Gateway Time-out”錯誤NginxGateway
- Roll-out 專案注意事項
- [深度學習]丟棄法(drop out)深度學習
- JAVA IPMI Command time out 解決方法Java
- 再不用ContraintLayout就out啦AI
- 使用Fan-Out模式併發處理模式
- [Clickhouse] Clickhouse 報SQLException : Read timed outSQLException