comparison models/model_7.py @ 0:457fd8fd681a draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/VirHunter commit 628688c1302dbf972e48806d2a5bafe27847bdcc
author iuc
date Wed, 09 Nov 2022 12:19:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:457fd8fd681a
1 from tensorflow.keras import layers, models
2
3
4 def launch(input_layer, hidden_layers):
5 output = input_layer
6 for hidden_layer in hidden_layers:
7 output = hidden_layer(output)
8 return output
9
10
11 def model(length, kernel_size=7, filters=256, dense_ns=256):
12 forward_input = layers.Input(shape=(length, 4))
13 reverse_input = layers.Input(shape=(length, 4))
14 hidden_layers = [
15 layers.Conv1D(filters=filters, kernel_size=kernel_size),
16 layers.LeakyReLU(alpha=0.1),
17 layers.GlobalMaxPooling1D(),
18 layers.Dropout(0.1),
19 ]
20 forward_output = launch(forward_input, hidden_layers)
21 reverse_output = launch(reverse_input, hidden_layers)
22 output = layers.Concatenate()([forward_output, reverse_output])
23 output = layers.Dense(dense_ns, activation='relu')(output)
24 output = layers.Dropout(0.1)(output)
25 # output = layers.Dense(128, activation='relu')(output)
26 # output = layers.Dropout(0.1)(output)
27 output = layers.Dense(3, activation='softmax')(output)
28 model_ = models.Model(inputs=[forward_input, reverse_input], outputs=output)
29 model_.compile(optimizer="adam", loss='categorical_crossentropy', metrics='accuracy')
30 return model_
31
32
33 # def model(length, kernel_size=7, filters=256, dense_ns=512):
34 # forward_input = layers.Input(shape=(length, 4))
35 # reverse_input = layers.Input(shape=(length, 4))
36 # hidden_layers = [
37 # layers.Conv1D(filters=filters, kernel_size=kernel_size),
38 # layers.MaxPool1D(pool_size=50, strides=25),
39 # layers.LSTM(32),
40 # ]
41 # forward_output = launch(forward_input, hidden_layers)
42 # reverse_output = launch(reverse_input, hidden_layers)
43 # output = layers.Concatenate()([forward_output, reverse_output])
44 # # output = layers.Dense(64, activation='relu')(output)
45 # output = layers.Dropout(0.1)(output)
46 # output = layers.Dense(3, activation='softmax')(output)
47 # model_ = models.Model(inputs=[forward_input, reverse_input], outputs=output)
48 # model_.compile(optimizer="adam", loss='categorical_crossentropy', metrics='accuracy')
49 # return model_