Skip to content

Commit f82f34c

Browse files
committed
fix confict
2 parents e50c763 + 71e103b commit f82f34c

File tree

9 files changed

+20
-28
lines changed

9 files changed

+20
-28
lines changed

tensorlayerx/nn/layers/Transformer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,15 @@ def __init__(
513513
self._config.pop("self")
514514
self._config.pop("__class__", None)
515515
self.self_attn = MultiheadAttention(d_model, nhead, dropout=dropout, batch_first=batch_first)
516-
self.linear1 = tlx.nn.layers.Dense(in_channels=d_model, n_units=dim_feedforward)
517-
self.dropout1 = tlx.nn.layers.Dropout(float(1.0 - dropout))
518-
self.linear2 = tlx.nn.layers.Dense(in_channels=dim_feedforward, n_units=d_model)
516+
self.linear1 = tlx.nn.layers.Linear(in_features=d_model, out_features=dim_feedforward)
517+
self.dropout1 = tlx.nn.layers.Dropout(float(dropout))
518+
self.linear2 = tlx.nn.layers.Linear(in_features=dim_feedforward, out_features=d_model)
519519

520520
self.norm1 = tlx.nn.layers.LayerNorm(d_model, epsilon=layer_norm_eps)
521521
self.norm2 = tlx.nn.layers.LayerNorm(d_model, epsilon=layer_norm_eps)
522522

523-
self.dropout2 = tlx.nn.layers.Dropout(float(1.0 - dropout))
524-
self.dropout3 = tlx.nn.layers.Dropout(float(1.0 - dropout))
523+
self.dropout2 = tlx.nn.layers.Dropout(float(dropout))
524+
self.dropout3 = tlx.nn.layers.Dropout(float(dropout))
525525
if act == 'relu':
526526
self.act = tlx.relu
527527
elif act == 'gelu':
@@ -608,14 +608,14 @@ def __init__(
608608
self._config.pop("__class__", None) # py3
609609
self.self_attn = MultiheadAttention(d_model, nhead, dropout=dropout, batch_first=batch_first)
610610
self.cross_attn = MultiheadAttention(d_model, nhead, dropout=dropout, batch_first=batch_first)
611-
self.dropout1 = tlx.nn.layers.Dropout(float(1 - dropout))
612-
self.dropout2 = tlx.nn.layers.Dropout(float(1 - dropout))
613-
self.dropout3 = tlx.nn.layers.Dropout(float(1 - dropout))
611+
self.dropout1 = tlx.nn.layers.Dropout(float(dropout))
612+
self.dropout2 = tlx.nn.layers.Dropout(float(dropout))
613+
self.dropout3 = tlx.nn.layers.Dropout(float(dropout))
614614
self.norm1 = tlx.nn.layers.LayerNorm(d_model, epsilon=layer_norm_eps)
615615
self.norm2 = tlx.nn.layers.LayerNorm(d_model, epsilon=layer_norm_eps)
616616
self.norm3 = tlx.nn.layers.LayerNorm(d_model, epsilon=layer_norm_eps)
617-
self.linear1 = tlx.nn.layers.Dense(in_channels=d_model, n_units=dim_feedforward)
618-
self.linear2 = tlx.nn.layers.Dense(in_channels=dim_feedforward, n_units=d_model)
617+
self.linear1 = tlx.nn.layers.Linear(in_features=d_model, out_features=dim_feedforward)
618+
self.linear2 = tlx.nn.layers.Linear(in_features=dim_feedforward, out_features=d_model)
619619

620620
if act == 'relu':
621621
self.act = tlx.relu

tests/layers/test_layers_core_basedense_dropout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setUpClass(self):
2323
self.dense1 = tlx.nn.Linear(out_features=800, act=tlx.ReLU, in_features=784, name='test_dense')
2424
self.n1 = self.dense1(self.input)
2525

26-
self.dropout1 = tlx.nn.Dropout(keep=0.8)
26+
self.dropout1 = tlx.nn.Dropout(p=0.2)
2727
self.n2 = self.dropout1(self.n1)
2828

2929
self.dense2 = tlx.nn.Linear(out_features=10, act='relu', b_init=None, in_features=800)
@@ -39,7 +39,7 @@ class get_model(tensorlayerx.nn.Module):
3939
def __init__(self):
4040
super(get_model, self).__init__()
4141
self.layer1 = tlx.nn.Linear(out_features=800, act=tlx.ReLU, in_features=784, name='test_dense')
42-
self.dp = tlx.nn.Dropout(p=0.8)
42+
self.dp = tlx.nn.Dropout(p=0.2)
4343
self.layer2 = tlx.nn.Linear(out_features=10, act='relu', b_init=None, in_features=800)
4444
self.layer3 = tlx.nn.Linear(out_features=10, act='relu', b_init=None, in_features=10)
4545

tests/layers/test_layers_core_nested.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MyLayer(tensorlayerx.nn.Module):
2727

2828
def __init__(self, name=None):
2929
super(MyLayer, self).__init__(name=name)
30-
self.input_layer = tlx.nn.Dense(in_channels=50, n_units=20)
30+
self.input_layer = tlx.nn.Linear(in_features=50, out_features=20)
3131
self.build(None)
3232
self._built = True
3333

tests/layers/test_layers_extend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import unittest
66

77
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
8-
import tensorlayerx
98
import tensorlayerx as tlx
109

1110
from tests.utils import CustomTestCase

tests/layers/test_layers_linear.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def setUpClass(self):
2121

2222
self.ni = tlx.nn.Input(self.inputs_shape, name='input_layer')
2323
self.layer1 = tlx.nn.BinaryLinear(out_features=5)
24-
2524
self.layer2 = tlx.nn.BinaryLinear(out_features=5, in_features=10)
2625

2726
self.n1 = self.layer1(self.ni)
@@ -76,9 +75,7 @@ def setUpClass(self):
7675

7776
self.ni = tlx.nn.Input(self.inputs_shape, name='input_layer')
7877
self.layer1 = tlx.nn.DropconnectLinear(out_features=5, keep=1.0)
79-
8078
self.layer2 = tlx.nn.DropconnectLinear(out_features=5, in_features=10, keep=0.01)
81-
8279
self.n1 = self.layer1(self.ni)
8380
self.n2 = self.layer2(self.ni)
8481

@@ -103,9 +100,7 @@ def setUpClass(self):
103100

104101
self.ni = tlx.nn.Input(self.inputs_shape, name='input_layer')
105102
self.layer1 = tlx.nn.QuanLinear(out_features=5)
106-
107103
self.layer2 = tlx.nn.QuanLinear(out_features=5, in_features=10)
108-
109104
self.n1 = self.layer1(self.ni)
110105
self.n2 = self.layer2(self.ni)
111106

tests/layers/test_layers_normalization.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setUpClass(cls):
2929

3030
## Base
3131
ni_1 = Input(x_1_input_shape, name='test_ni1')
32-
nn_1 = Conv1d(out_channels=32, kernel_size=5, stride=2, name='test_conv1d')(ni_1)
32+
nn_1 = Conv1d(out_channels=32, in_channels=1, stride=2, name='test_conv1d')(ni_1)
3333
n1_b = BatchNorm(name='test_conv')(nn_1)
3434
cls.n1_b = n1_b
3535

@@ -47,7 +47,7 @@ class bn_0d_model(tlx.nn.Module):
4747

4848
def __init__(self):
4949
super(bn_0d_model, self).__init__()
50-
self.fc = Dense(32, in_channels=10)
50+
self.fc = Linear(32, in_features=10)
5151
self.bn = BatchNorm(num_features=32, name='test_bn1d')
5252

5353
def forward(self, x):
@@ -61,7 +61,7 @@ def forward(self, x):
6161

6262
nin_0 = Input(x_0_input_shape, name='test_in1')
6363

64-
n0 = Dense(32)(nin_0)
64+
n0 = Linear(32)(nin_0)
6565
n0 = BatchNorm1d(name='test_bn0d')(n0)
6666

6767
cls.n0 = n0
@@ -70,7 +70,7 @@ class bn_0d_model(tlx.nn.Module):
7070

7171
def __init__(self):
7272
super(bn_0d_model, self).__init__(name='test_bn_0d_model')
73-
self.fc = Dense(32, in_channels=10)
73+
self.fc = Linear(32, in_features=10)
7474
self.bn = BatchNorm1d(num_features=32, name='test_bn1d')
7575

7676
def forward(self, x):
@@ -104,7 +104,6 @@ def forward(self, x):
104104
## 2D ========================================================================
105105

106106
nin_2 = Input(x_2_input_shape, name='test_in2')
107-
108107
n2 = Conv2d(out_channels=32, kernel_size=(3, 3), stride=(2, 2), name='test_conv2d')(nin_2)
109108
n2 = BatchNorm2d(name='test_bn2d')(n2)
110109

@@ -126,7 +125,6 @@ def forward(self, x):
126125
## 3D ========================================================================
127126

128127
nin_3 = Input(x_3_input_shape, name='test_in3')
129-
130128
n3 = Conv3d(out_channels=32, kernel_size=(3, 3, 3), stride=(2, 2, 2), name='test_conv3d')(nin_3)
131129
n3 = BatchNorm3d(name='test_bn3d', act=tlx.ReLU)(n3)
132130

tests/layers/test_layers_pooling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def setUpClass(cls):
4646

4747
x_2_input_shape = [None, 100, 100, 3]
4848
nin_2 = Input(x_2_input_shape, name='test_in2')
49-
5049
n6 = tlx.nn.Conv2d(out_channels=32, kernel_size=(3, 3), stride=(2, 2), name='test_conv2d')(nin_2)
5150
n7 = tlx.nn.MaxPool2d(kernel_size=(3, 3), stride=(2, 2), padding='SAME',
5251
name='test_maxpool2d')(n6)

tests/layers/test_layers_resampling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def setUpClass(cls):
2626
x_2_input_shape = [None, 100, 100, 3]
2727
nin_2 = Input(x_2_input_shape)
2828

29+
2930
n6 = tlx.nn.Conv2d(out_channels=32, kernel_size=(3, 3), stride=(2, 2), name='test_conv2d')(nin_2)
3031

3132
n7 = tlx.nn.UpSampling2d(scale=(2, 2), name='test_UpSampling2d_1')(n6)

tests/layers/test_mindspore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ def test_pooling():
190190

191191
def test_dense():
192192
input_layer = tlx.nn.Input([10, 30])
193-
n1 = tlx.nn.Dense(n_units=100, in_channels=30, b_init=tlx.initializers.truncated_normal())(input_layer)
194-
n2 = tlx.nn.Dense(n_units=10, name='none inchannels')(input_layer)
193+
n1 = tlx.nn.Linear(out_features=100, in_features=30, b_init=tlx.initializers.truncated_normal())(input_layer)
194+
n2 = tlx.nn.Linear(out_features=10, name='none inchannels')(input_layer)
195195
print("Dense :", n1.shape, n2.shape)
196196

197197
def test_normalization():

0 commit comments

Comments
 (0)