Skip to content

Commit 5c186b1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3d9b893 commit 5c186b1

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

neural_network/lstm.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,22 @@ def initialize_weights(self) -> None:
9797
Initialize the weights and biases for the LSTM network.
9898
"""
9999

100-
self.wf = self.init_weights(
101-
self.char_size + self.hidden_dim, self.hidden_dim
102-
)
100+
self.wf = self.init_weights(self.char_size + self.hidden_dim, self.hidden_dim)
103101
self.bf = np.zeros((self.hidden_dim, 1))
104102

105-
self.wi = self.init_weights(
106-
self.char_size + self.hidden_dim, self.hidden_dim
107-
)
103+
self.wi = self.init_weights(self.char_size + self.hidden_dim, self.hidden_dim)
108104
self.bi = np.zeros((self.hidden_dim, 1))
109105

110-
self.wc = self.init_weights(
111-
self.char_size + self.hidden_dim, self.hidden_dim
112-
)
106+
self.wc = self.init_weights(self.char_size + self.hidden_dim, self.hidden_dim)
113107
self.bc = np.zeros((self.hidden_dim, 1))
114108

115-
self.wo = self.init_weights(
116-
self.char_size + self.hidden_dim, self.hidden_dim
117-
)
109+
self.wo = self.init_weights(self.char_size + self.hidden_dim, self.hidden_dim)
118110
self.bo = np.zeros((self.hidden_dim, 1))
119111

120112
self.wy = self.init_weights(self.hidden_dim, self.char_size)
121113
self.by = np.zeros((self.char_size, 1))
122114

123-
def init_weights(
124-
self, input_dim: int, output_dim: int
125-
) -> np.ndarray:
115+
def init_weights(self, input_dim: int, output_dim: int) -> np.ndarray:
126116
"""
127117
Initialize weights with random values.
128118
@@ -367,7 +357,6 @@ def test(self) -> None:
367357
print(f"Accuracy: {round(accuracy * 100 / len(self.train_X), 2)}%")
368358

369359

370-
371360
if __name__ == "__main__":
372361
data = """Long Short-Term Memory (LSTM) networks are a type
373362
of recurrent neural network (RNN) capable of learning "

0 commit comments

Comments
 (0)