MCPcopy Create free account
hub / github.com/FinancialComputingUCL/LOBFrame / DeepLOB

Class DeepLOB

models/DeepLob/deeplob.py:6–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class DeepLOB(pl.LightningModule):
7 def __init__(self, lighten):
8 super().__init__()
9 self.name = "deeplob"
10 if lighten:
11 self.name += "-lighten"
12
13 # Convolution blocks.
14 self.conv1 = nn.Sequential(
15 nn.Conv2d(
16 in_channels=1, out_channels=32, kernel_size=(1, 2), stride=(1, 2)
17 ),
18 nn.LeakyReLU(negative_slope=0.01),
19 nn.BatchNorm2d(32),
20 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
21 nn.LeakyReLU(negative_slope=0.01),
22 nn.BatchNorm2d(32),
23 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
24 nn.LeakyReLU(negative_slope=0.01),
25 nn.BatchNorm2d(32),
26 )
27 self.conv2 = nn.Sequential(
28 nn.Conv2d(
29 in_channels=32, out_channels=32, kernel_size=(1, 2), stride=(1, 2)
30 ),
31 nn.LeakyReLU(negative_slope=0.01),
32 nn.BatchNorm2d(32),
33 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
34 nn.LeakyReLU(negative_slope=0.01),
35 nn.BatchNorm2d(32),
36 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
37 nn.LeakyReLU(negative_slope=0.01),
38 nn.BatchNorm2d(32),
39 )
40
41 if lighten:
42 conv3_kernel_size = 5
43 else:
44 conv3_kernel_size = 10
45
46 self.conv3 = nn.Sequential(
47 nn.Conv2d(
48 in_channels=32, out_channels=32, kernel_size=(1, conv3_kernel_size)
49 ),
50 nn.LeakyReLU(negative_slope=0.01),
51 nn.BatchNorm2d(32),
52 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
53 nn.LeakyReLU(negative_slope=0.01),
54 nn.BatchNorm2d(32),
55 nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(4, 1)),
56 nn.LeakyReLU(negative_slope=0.01),
57 nn.BatchNorm2d(32),
58 )
59
60 # Inception modules.
61 self.inp1 = nn.Sequential(
62 nn.Conv2d(
63 in_channels=32, out_channels=64, kernel_size=(1, 1), padding="same"

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected