Skip to content

Commit

Permalink
使用高效版卷积核池化构建module
Browse files Browse the repository at this point in the history
  • Loading branch information
yizt committed Apr 25, 2020
1 parent 03d7f32 commit 9b95ce6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nn/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def __init__(self, in_units, out_units, **kwargs):
"""
super(Linear, self).__init__(**kwargs)
# 权重参数
weight = np.random.randn(in_units, out_units).astype(np.float32) * np.sqrt(2 / in_units)
bias = np.zeros(out_units).astype(np.float32)
weight = np.random.randn(in_units, out_units) * np.sqrt(2 / in_units)
bias = np.zeros(out_units)
# 权重对应的梯度
g_weight = np.zeros_like(weight)
g_bias = np.zeros_like(bias)
Expand Down Expand Up @@ -183,8 +183,8 @@ def __init__(self, in_filters, out_filters, kernel=(3, 3), padding=(1, 1), strid
fan_out = out_filters * kernel[0] * kernel[1] # 输入参数量
weight = np.random.randn(in_filters,
out_filters,
*kernel).astype(np.float32) * np.sqrt(2 / (fan_in + fan_out))
bias = np.zeros(out_filters).astype(np.float32)
*kernel) * np.sqrt(2 / (fan_in + fan_out))
bias = np.zeros(out_filters)
# 梯度
g_weight = np.zeros_like(weight)
g_bias = np.zeros_like(bias)
Expand Down

0 comments on commit 9b95ce6

Please sign in to comment.