Datasets:
general
Browse files- the_code/General/Generative_model.html +0 -0
- the_code/General/Generative_model.ipynb +127 -0
- the_code/General/Motif_implantation.html +0 -0
- the_code/General/Motif_implantation.ipynb +0 -0
- the_code/General/Sequence_evolution.html +0 -0
- the_code/General/Sequence_evolution.ipynb +0 -0
- the_code/General/data/DeepFlyBrain_data.pkl +3 -0
- the_code/General/data/DeepMEL2_data.pkl +3 -0
- the_code/General/data/KC_regions.fa +3 -0
- the_code/General/data/MEL_regions.fa +3 -0
- the_code/General/models/DeepFlyBrain/DeepFlyBrain_architecture.json +1 -0
- the_code/General/models/DeepFlyBrain/DeepFlyBrain_weights.hdf5 +3 -0
- the_code/General/models/DeepMEL2/DeepMEL2_architecture.json +1 -0
- the_code/General/models/DeepMEL2/DeepMEL2_weights.hdf5 +3 -0
- the_code/General/models/KC_GAN/KC_GAN_disc_architecture.json +1 -0
- the_code/General/models/KC_GAN/KC_GAN_disc_iter210k_weights.hdf5 +3 -0
- the_code/General/models/KC_GAN/KC_GAN_gen_architecture.json +1 -0
- the_code/General/models/KC_GAN/KC_GAN_gen_iter210k_weights.hdf5 +3 -0
- the_code/General/models/MEL_GAN/MEL_GAN_disc_architecture.json +1 -0
- the_code/General/models/MEL_GAN/MEL_GAN_disc_iter160k_weights.hdf5 +3 -0
- the_code/General/models/MEL_GAN/MEL_GAN_gen_architecture.json +1 -0
- the_code/General/models/MEL_GAN/MEL_GAN_gen_iter160k_weights.hdf5 +3 -0
- the_code/General/output/testdata_motif_implant_100seqs.pkl +3 -0
- the_code/General/output/testdata_sequence_evolution_10seqs.pkl +3 -0
- the_code/General/utils.py +412 -0
- the_code/General/wgan_gp.py +344 -0
the_code/General/Generative_model.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
the_code/General/Generative_model.ipynb
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "3b921d47-d760-4438-b754-8a6d805e9415",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"### The GAN models were trained using a conda environment. Below you can find how to create the same environment to train GAN models and generate sequences"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"cell_type": "code",
|
| 13 |
+
"execution_count": null,
|
| 14 |
+
"id": "0cd67f38-a1bf-4234-bbad-cf5baa718e59",
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"# %%bash\n",
|
| 19 |
+
"# conda create --name deeplearning_py36_tf114_gpu python=3.6 tensorflow-gpu=1.14.0 keras-gpu=2.2.4\n",
|
| 20 |
+
"# conda activate deeplearning_py36_tf114_gpu\n",
|
| 21 |
+
"# conda install numpy=1.16.2 matplotlib=3.1.1 shap=0.29.3 ipykernel=5.1.2"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "markdown",
|
| 26 |
+
"id": "a03be807-48c6-42c9-90ec-f1a2e16d95f1",
|
| 27 |
+
"metadata": {},
|
| 28 |
+
"source": [
|
| 29 |
+
"### Below you can find explanation of parameters that were used to train model and generate sequences.\n",
|
| 30 |
+
"#### (These variables can be found in the beginning of __wgan_gp.py__)"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"cell_type": "markdown",
|
| 35 |
+
"id": "3a272a4a-71da-40ac-9906-a74c62bfe3f8",
|
| 36 |
+
"metadata": {},
|
| 37 |
+
"source": [
|
| 38 |
+
"__BATCH_SIZE__: Batch size (how many regions will be used in each iteration). \\\n",
|
| 39 |
+
"__ITERS__: Number of batch iterations to train the model. \\\n",
|
| 40 |
+
"__SEQ_LEN__: Length of the input sequences. \\\n",
|
| 41 |
+
"__SEQ_DIM__: Dimension of the input sequences. (4 nucleotides) \\\n",
|
| 42 |
+
"__DIM__: Dimension of the model. It is used in latent space and convolutional layers. \\\n",
|
| 43 |
+
"__CRITIC_ITERS__: How many training iterations will be done for Discriminator for each Generator iteration. \\\n",
|
| 44 |
+
"__LAMBDA__: Hyperparameter for gradient penalty. \\\n",
|
| 45 |
+
"__loginterval__: Once every N iteration the log will be saved. \\\n",
|
| 46 |
+
"__seqinterval__: Once every N iteration the sample sequences will be generated. \\\n",
|
| 47 |
+
"__modelinterval__: Once every N iteration the model files will be saved. \\\n",
|
| 48 |
+
"__selectedmodel__: When generating sequences, the iteration number of the model you want to use. \\\n",
|
| 49 |
+
"__suffix__: When generating sequences, the suffix to add to the header of the fasta regions. \\\n",
|
| 50 |
+
"__ngenerate__: When generating sequences, number of sequences you want to generate relative to batchsize. Example: 1 (128 sequences will be generated if the batch size is 128) \\\n",
|
| 51 |
+
"__outputdirc__: Path the to output folder. \\\n",
|
| 52 |
+
"__fastafile__: Path to the fasta file to use as real enhancers "
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"cell_type": "markdown",
|
| 57 |
+
"id": "9a4ab1ed-8973-4026-9d66-98f2ca6d764d",
|
| 58 |
+
"metadata": {},
|
| 59 |
+
"source": [
|
| 60 |
+
"### How to run the model"
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"cell_type": "code",
|
| 65 |
+
"execution_count": null,
|
| 66 |
+
"id": "832087a8-fa27-4250-bb4e-066a52ded090",
|
| 67 |
+
"metadata": {},
|
| 68 |
+
"outputs": [],
|
| 69 |
+
"source": [
|
| 70 |
+
"# %%bash\n",
|
| 71 |
+
"# conda activate deeplearning_py36_tf114_gpu\n",
|
| 72 |
+
"# python wgan_gp.py"
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"cell_type": "markdown",
|
| 77 |
+
"id": "efc65b44-515e-4dd8-9bb9-81d1f0ceaa13",
|
| 78 |
+
"metadata": {},
|
| 79 |
+
"source": [
|
| 80 |
+
"### This will result following outputs"
|
| 81 |
+
]
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"cell_type": "markdown",
|
| 85 |
+
"id": "cb3d54fd-11d2-4fa8-92c7-b85c4007ad00",
|
| 86 |
+
"metadata": {},
|
| 87 |
+
"source": [
|
| 88 |
+
"__./models/__: Folder containing saved model's weight files. \\\n",
|
| 89 |
+
"__./samples_ACGT/__: Folder containing sampled sequences during training. \\\n",
|
| 90 |
+
"__./samples_raw/__: Folder containing sampled sequences (in their raw format) during training. \\\n",
|
| 91 |
+
"__./gen_seq/__: Folder containing generated sequences after training. \\\n",
|
| 92 |
+
"__./disc.json__: Architecture file of the discriminator. \\\n",
|
| 93 |
+
"__./gen.json__: Architecture file of the generator. \\\n",
|
| 94 |
+
"__./d_g_loss.pkl__: Logged loss values during training. "
|
| 95 |
+
]
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"cell_type": "code",
|
| 99 |
+
"execution_count": null,
|
| 100 |
+
"id": "9aa94e0f-263e-4ad1-967e-059770526381",
|
| 101 |
+
"metadata": {},
|
| 102 |
+
"outputs": [],
|
| 103 |
+
"source": []
|
| 104 |
+
}
|
| 105 |
+
],
|
| 106 |
+
"metadata": {
|
| 107 |
+
"kernelspec": {
|
| 108 |
+
"display_name": "Deeplearning tf1.15",
|
| 109 |
+
"language": "python",
|
| 110 |
+
"name": "deeplearning_tf115"
|
| 111 |
+
},
|
| 112 |
+
"language_info": {
|
| 113 |
+
"codemirror_mode": {
|
| 114 |
+
"name": "ipython",
|
| 115 |
+
"version": 3
|
| 116 |
+
},
|
| 117 |
+
"file_extension": ".py",
|
| 118 |
+
"mimetype": "text/x-python",
|
| 119 |
+
"name": "python",
|
| 120 |
+
"nbconvert_exporter": "python",
|
| 121 |
+
"pygments_lexer": "ipython3",
|
| 122 |
+
"version": "3.7.10"
|
| 123 |
+
}
|
| 124 |
+
},
|
| 125 |
+
"nbformat": 4,
|
| 126 |
+
"nbformat_minor": 5
|
| 127 |
+
}
|
the_code/General/Motif_implantation.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
the_code/General/Motif_implantation.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
the_code/General/Sequence_evolution.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
the_code/General/Sequence_evolution.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
the_code/General/data/DeepFlyBrain_data.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:539426217f24e20875458349dafc416d87df0812076ae324b816d6c36cc036d8
|
| 3 |
+
size 554306501
|
the_code/General/data/DeepMEL2_data.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c7d5f0bb2c5a31d5d49b68ced4d0f0e6c145a16791f8d499a7638fb23e91e4a
|
| 3 |
+
size 440085279
|
the_code/General/data/KC_regions.fa
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d5bd02465af461311c68bf32890d8b015ddfa53e4cf21620fa22ab4e439c859
|
| 3 |
+
size 3216920
|
the_code/General/data/MEL_regions.fa
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2acfc770926abdb83c085808e2900abf75855a20e652402d5267f3380e02925c
|
| 3 |
+
size 2047064
|
the_code/General/models/DeepFlyBrain/DeepFlyBrain_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "lambda_2", "class_name": "Lambda", "config": {"name": "lambda_2", "trainable": true, "function": ["4wEAAAAAAAAAAQAAAAQAAABDAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4ZXMp\nAtoBS9oHcmV2ZXJzZSkB2gF4qQByBgAAAPqjL2RkbjEvdm9sMS9zdGFnaW5nL2xldXZlbi9zdGdf\nMDAwMDIvbGNiL2l0YXNrL2RlZXBfbGVhcm5pbmcvZGVlcEZMWS9hZHVsdEJyYWluX25ldy9LQ19U\nX0dsaWEvODF0b3BpY3NfMDk3NS90Zl9tb3RpZnNfbWluMDI1X25vZGl2X21wc3QxNl9oaWdoZG9f\nbW9yZWZpbHRlci91dGlscy5wedoIPGxhbWJkYT4RAQAA8wAAAAA=\n", null, null], "function_type": "lambda", "output_shape": null, "output_shape_type": "raw", "arguments": {}}, "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"name": "lambda_1", "class_name": "Lambda", "config": {"name": "lambda_1", "trainable": true, "function": ["4wEAAAAAAAAAAQAAAAQAAABDAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukCAAAAKQHaBGF4ZXMp\nAtoBS9oHcmV2ZXJzZSkB2gF4qQByBgAAAPqjL2RkbjEvdm9sMS9zdGFnaW5nL2xldXZlbi9zdGdf\nMDAwMDIvbGNiL2l0YXNrL2RlZXBfbGVhcm5pbmcvZGVlcEZMWS9hZHVsdEJyYWluX25ldy9LQ19U\nX0dsaWEvODF0b3BpY3NfMDk3NS90Zl9tb3RpZnNfbWluMDI1X25vZGl2X21wc3QxNl9oaWdoZG9f\nbW9yZWZpbHRlci91dGlscy5wedoIPGxhbWJkYT4QAQAA8wAAAAA=\n", null, null], "function_type": "lambda", "output_shape": null, "output_shape_type": "raw", "arguments": {}}, "inbound_nodes": [[["lambda_2", 0, 0, {}]]]}, {"name": "conv1d_1", "class_name": "Conv1D", "config": {"name": "conv1d_1", "trainable": true, "filters": 1024, "kernel_size": [24], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "RandomUniform", "config": {"minval": -0.05, "maxval": 0.05, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["input_1", 0, 0, {}]], [["lambda_1", 0, 0, {}]]]}, {"name": "max_pooling1d_1", "class_name": "MaxPooling1D", "config": {"name": "max_pooling1d_1", "trainable": true, "strides": [12], "pool_size": [12], "padding": "valid", "data_format": "channels_last"}, "inbound_nodes": [[["conv1d_1", 0, 0, {}]], [["conv1d_1", 1, 0, {}]]]}, {"name": "dropout_1", "class_name": "Dropout", "config": {"name": "dropout_1", "trainable": true, "rate": 0.5, "noise_shape": null, "seed": null}, "inbound_nodes": [[["max_pooling1d_1", 0, 0, {}]], [["max_pooling1d_1", 1, 0, {}]]]}, {"name": "time_distributed_1", "class_name": "TimeDistributed", "config": {"name": "time_distributed_1", "trainable": true, "layer": {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}}, "inbound_nodes": [[["dropout_1", 0, 0, {}]], [["dropout_1", 1, 0, {}]]]}, {"name": "bidirectional_1", "class_name": "Bidirectional", "config": {"name": "bidirectional_1", "trainable": true, "layer": {"class_name": "LSTM", "config": {"name": "lstm_1", "trainable": true, "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "units": 128, "activation": "tanh", "recurrent_activation": "hard_sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.2, "recurrent_dropout": 0.2, "implementation": 1}}, "merge_mode": "concat"}, "inbound_nodes": [[["time_distributed_1", 0, 0, {}]], [["time_distributed_1", 1, 0, {}]]]}, {"name": "dropout_2", "class_name": "Dropout", "config": {"name": "dropout_2", "trainable": true, "rate": 0.5, "noise_shape": null, "seed": null}, "inbound_nodes": [[["bidirectional_1", 0, 0, {}]], [["bidirectional_1", 1, 0, {}]]]}, {"name": "flatten_1", "class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "data_format": "channels_last"}, "inbound_nodes": [[["dropout_2", 0, 0, {}]], [["dropout_2", 1, 0, {}]]]}, {"name": "dense_2", "class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 256, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["flatten_1", 0, 0, {}]], [["flatten_1", 1, 0, {}]]]}, {"name": "dropout_3", "class_name": "Dropout", "config": {"name": "dropout_3", "trainable": true, "rate": 0.5, "noise_shape": null, "seed": null}, "inbound_nodes": [[["dense_2", 0, 0, {}]], [["dense_2", 1, 0, {}]]]}, {"name": "concatenate_1", "class_name": "Concatenate", "config": {"name": "concatenate_1", "trainable": true, "axis": 1}, "inbound_nodes": [[["dropout_3", 0, 0, {}], ["dropout_3", 1, 0, {}]]]}, {"name": "dense_3", "class_name": "Dense", "config": {"name": "dense_3", "trainable": true, "units": 81, "activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["concatenate_1", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["dense_3", 0, 0]]}, "keras_version": "2.2.4", "backend": "tensorflow"}
|
the_code/General/models/DeepFlyBrain/DeepFlyBrain_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d1d25f752658cda489dde3a558574cdedf64ca0cf743b9ce113b8d158a6d300
|
| 3 |
+
size 12921600
|
the_code/General/models/DeepMEL2/DeepMEL2_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "input_2", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_2"}, "inbound_nodes": []}, {"name": "conv1d_1", "class_name": "Conv1D", "config": {"name": "conv1d_1", "trainable": true, "dtype": "float32", "filters": 300, "kernel_size": [30], "strides": [1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "RandomUniform", "config": {"minval": -0.05, "maxval": 0.05, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["input_1", 0, 0, {}]], [["input_2", 0, 0, {}]]]}, {"name": "max_pooling1d_1", "class_name": "MaxPooling1D", "config": {"name": "max_pooling1d_1", "trainable": true, "dtype": "float32", "strides": [5], "pool_size": [15], "padding": "valid", "data_format": "channels_last"}, "inbound_nodes": [[["conv1d_1", 0, 0, {}]], [["conv1d_1", 1, 0, {}]]]}, {"name": "dropout_1", "class_name": "Dropout", "config": {"name": "dropout_1", "trainable": true, "dtype": "float32", "rate": 0.2, "noise_shape": null, "seed": null}, "inbound_nodes": [[["max_pooling1d_1", 0, 0, {}]], [["max_pooling1d_1", 1, 0, {}]]]}, {"name": "time_distributed_1", "class_name": "TimeDistributed", "config": {"name": "time_distributed_1", "trainable": true, "dtype": "float32", "layer": {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}}, "inbound_nodes": [[["dropout_1", 0, 0, {}]], [["dropout_1", 1, 0, {}]]]}, {"name": "bidirectional_1", "class_name": "Bidirectional", "config": {"name": "bidirectional_1", "trainable": true, "dtype": "float32", "layer": {"class_name": "LSTM", "config": {"name": "lstm_1", "trainable": true, "dtype": "float32", "return_sequences": true, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "units": 128, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.1, "recurrent_dropout": 0.1, "implementation": 2}}, "merge_mode": "concat"}, "inbound_nodes": [[["time_distributed_1", 0, 0, {}]], [["time_distributed_1", 1, 0, {}]]]}, {"name": "dropout_2", "class_name": "Dropout", "config": {"name": "dropout_2", "trainable": true, "dtype": "float32", "rate": 0.2, "noise_shape": null, "seed": null}, "inbound_nodes": [[["bidirectional_1", 0, 0, {}]], [["bidirectional_1", 1, 0, {}]]]}, {"name": "flatten_1", "class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "inbound_nodes": [[["dropout_2", 0, 0, {}]], [["dropout_2", 1, 0, {}]]]}, {"name": "dense_2", "class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "dtype": "float32", "units": 256, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["flatten_1", 0, 0, {}]], [["flatten_1", 1, 0, {}]]]}, {"name": "dropout_3", "class_name": "Dropout", "config": {"name": "dropout_3", "trainable": true, "dtype": "float32", "rate": 0.4, "noise_shape": null, "seed": null}, "inbound_nodes": [[["dense_2", 0, 0, {}]], [["dense_2", 1, 0, {}]]]}, {"name": "dense_3", "class_name": "Dense", "config": {"name": "dense_3", "trainable": true, "dtype": "float32", "units": 47, "activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["dropout_3", 0, 0, {}]], [["dropout_3", 1, 0, {}]]]}, {"name": "average_1", "class_name": "Average", "config": {"name": "average_1", "trainable": true, "dtype": "float32"}, "inbound_nodes": [[["dense_3", 0, 0, {}], ["dense_3", 1, 0, {}]]]}], "input_layers": [["input_1", 0, 0], ["input_2", 0, 0]], "output_layers": [["average_1", 0, 0]]}, "keras_version": "2.3.1", "backend": "tensorflow"}
|
the_code/General/models/DeepMEL2/DeepMEL2_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:636b0f1b7a54af4a1f07a46aa6d5c814aae9daad84e95c98974656abc81481b7
|
| 3 |
+
size 25550328
|
the_code/General/models/KC_GAN/KC_GAN_disc_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_13", "layers": [{"name": "input_14", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_14"}, "inbound_nodes": []}, {"name": "input_13", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_13"}, "inbound_nodes": []}, {"name": "model_6", "class_name": "Model", "config": {"name": "model_6", "layers": [{"name": "input_6", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_6"}, "inbound_nodes": []}, {"name": "sequential_1", "class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "batch_input_shape": [null, 128], "dtype": "float32", "units": 64000, "activation": "elu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Reshape", "config": {"name": "reshape_1", "trainable": true, "target_shape": [500, 128]}}, {"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "activation_2", "class_name": "Activation", "config": {"name": "activation_2", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"name": "conv1d_2", "class_name": "Conv1D", "config": {"name": "conv1d_2", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_2", 0, 0, {}]]]}, {"name": "add_1", "class_name": "Add", "config": {"name": "add_1", "trainable": true}, "inbound_nodes": [[["input_1", 0, 0, {}], ["conv1d_2", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["add_1", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_2", "layers": [{"name": "input_2", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_2"}, "inbound_nodes": []}, {"name": "activation_4", "class_name": "Activation", "config": {"name": "activation_4", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_2", 0, 0, {}]]]}, {"name": "conv1d_4", "class_name": "Conv1D", "config": {"name": "conv1d_4", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_4", 0, 0, {}]]]}, {"name": "add_2", "class_name": "Add", "config": {"name": "add_2", "trainable": true}, "inbound_nodes": [[["input_2", 0, 0, {}], ["conv1d_4", 0, 0, {}]]]}], "input_layers": [["input_2", 0, 0]], "output_layers": [["add_2", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_3", "layers": [{"name": "input_3", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_3"}, "inbound_nodes": []}, {"name": "activation_6", "class_name": "Activation", "config": {"name": "activation_6", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_3", 0, 0, {}]]]}, {"name": "conv1d_6", "class_name": "Conv1D", "config": {"name": "conv1d_6", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_6", 0, 0, {}]]]}, {"name": "add_3", "class_name": "Add", "config": {"name": "add_3", "trainable": true}, "inbound_nodes": [[["input_3", 0, 0, {}], ["conv1d_6", 0, 0, {}]]]}], "input_layers": [["input_3", 0, 0]], "output_layers": [["add_3", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_4", "layers": [{"name": "input_4", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_4"}, "inbound_nodes": []}, {"name": "activation_8", "class_name": "Activation", "config": {"name": "activation_8", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_4", 0, 0, {}]]]}, {"name": "conv1d_8", "class_name": "Conv1D", "config": {"name": "conv1d_8", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_8", 0, 0, {}]]]}, {"name": "add_4", "class_name": "Add", "config": {"name": "add_4", "trainable": true}, "inbound_nodes": [[["input_4", 0, 0, {}], ["conv1d_8", 0, 0, {}]]]}], "input_layers": [["input_4", 0, 0]], "output_layers": [["add_4", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_5", "layers": [{"name": "input_5", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_5"}, "inbound_nodes": []}, {"name": "activation_10", "class_name": "Activation", "config": {"name": "activation_10", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_5", 0, 0, {}]]]}, {"name": "conv1d_10", "class_name": "Conv1D", "config": {"name": "conv1d_10", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_10", 0, 0, {}]]]}, {"name": "add_5", "class_name": "Add", "config": {"name": "add_5", "trainable": true}, "inbound_nodes": [[["input_5", 0, 0, {}], ["conv1d_10", 0, 0, {}]]]}], "input_layers": [["input_5", 0, 0]], "output_layers": [["add_5", 0, 0]]}}, {"class_name": "Conv1D", "config": {"name": "conv1d_11", "trainable": true, "filters": 4, "kernel_size": [1], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Activation", "config": {"name": "activation_11", "trainable": true, "activation": "softmax"}}]}, "inbound_nodes": [[["input_6", 0, 0, {}]]]}], "input_layers": [["input_6", 0, 0]], "output_layers": [["sequential_1", 1, 0]]}, "inbound_nodes": [[["input_14", 0, 0, {}]]]}, {"name": "random_weighted_average_1", "class_name": "RandomWeightedAverage", "config": {"name": "random_weighted_average_1", "trainable": true}, "inbound_nodes": [[["input_13", 0, 0, {}], ["model_6", 1, 0, {}]]]}, {"name": "model_12", "class_name": "Model", "config": {"name": "model_12", "layers": [{"name": "input_12", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_12"}, "inbound_nodes": []}, {"name": "sequential_2", "class_name": "Sequential", "config": {"name": "sequential_2", "layers": [{"class_name": "Conv1D", "config": {"name": "conv1d_12", "trainable": true, "batch_input_shape": [null, 500, 4], "dtype": "float32", "filters": 128, "kernel_size": [1], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Model", "config": {"name": "model_7", "layers": [{"name": "input_7", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_7"}, "inbound_nodes": []}, {"name": "activation_13", "class_name": "Activation", "config": {"name": "activation_13", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_7", 0, 0, {}]]]}, {"name": "conv1d_14", "class_name": "Conv1D", "config": {"name": "conv1d_14", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_13", 0, 0, {}]]]}, {"name": "add_6", "class_name": "Add", "config": {"name": "add_6", "trainable": true}, "inbound_nodes": [[["input_7", 0, 0, {}], ["conv1d_14", 0, 0, {}]]]}], "input_layers": [["input_7", 0, 0]], "output_layers": [["add_6", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_8", "layers": [{"name": "input_8", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_8"}, "inbound_nodes": []}, {"name": "activation_15", "class_name": "Activation", "config": {"name": "activation_15", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_8", 0, 0, {}]]]}, {"name": "conv1d_16", "class_name": "Conv1D", "config": {"name": "conv1d_16", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_15", 0, 0, {}]]]}, {"name": "add_7", "class_name": "Add", "config": {"name": "add_7", "trainable": true}, "inbound_nodes": [[["input_8", 0, 0, {}], ["conv1d_16", 0, 0, {}]]]}], "input_layers": [["input_8", 0, 0]], "output_layers": [["add_7", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_9", "layers": [{"name": "input_9", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_9"}, "inbound_nodes": []}, {"name": "activation_17", "class_name": "Activation", "config": {"name": "activation_17", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_9", 0, 0, {}]]]}, {"name": "conv1d_18", "class_name": "Conv1D", "config": {"name": "conv1d_18", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_17", 0, 0, {}]]]}, {"name": "add_8", "class_name": "Add", "config": {"name": "add_8", "trainable": true}, "inbound_nodes": [[["input_9", 0, 0, {}], ["conv1d_18", 0, 0, {}]]]}], "input_layers": [["input_9", 0, 0]], "output_layers": [["add_8", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_10", "layers": [{"name": "input_10", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_10"}, "inbound_nodes": []}, {"name": "activation_19", "class_name": "Activation", "config": {"name": "activation_19", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_10", 0, 0, {}]]]}, {"name": "conv1d_20", "class_name": "Conv1D", "config": {"name": "conv1d_20", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_19", 0, 0, {}]]]}, {"name": "add_9", "class_name": "Add", "config": {"name": "add_9", "trainable": true}, "inbound_nodes": [[["input_10", 0, 0, {}], ["conv1d_20", 0, 0, {}]]]}], "input_layers": [["input_10", 0, 0]], "output_layers": [["add_9", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_11", "layers": [{"name": "input_11", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_11"}, "inbound_nodes": []}, {"name": "activation_21", "class_name": "Activation", "config": {"name": "activation_21", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_11", 0, 0, {}]]]}, {"name": "conv1d_22", "class_name": "Conv1D", "config": {"name": "conv1d_22", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_21", 0, 0, {}]]]}, {"name": "add_10", "class_name": "Add", "config": {"name": "add_10", "trainable": true}, "inbound_nodes": [[["input_11", 0, 0, {}], ["conv1d_22", 0, 0, {}]]]}], "input_layers": [["input_11", 0, 0]], "output_layers": [["add_10", 0, 0]]}}, {"class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 1, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "inbound_nodes": [[["input_12", 0, 0, {}]]]}], "input_layers": [["input_12", 0, 0]], "output_layers": [["sequential_2", 1, 0]]}, "inbound_nodes": [[["model_6", 1, 0, {}]], [["input_13", 0, 0, {}]], [["random_weighted_average_1", 0, 0, {}]]]}], "input_layers": [["input_13", 0, 0], ["input_14", 0, 0]], "output_layers": [["model_12", 2, 0], ["model_12", 1, 0], ["model_12", 3, 0]]}, "keras_version": "2.2.4", "backend": "tensorflow"}
|
the_code/General/models/KC_GAN/KC_GAN_disc_iter210k_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:086fbe9665607a29675a61acc4efd0f85094cda4eedef42e00c8040bbf454937
|
| 3 |
+
size 36600388
|
the_code/General/models/KC_GAN/KC_GAN_gen_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_14", "layers": [{"name": "input_15", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_15"}, "inbound_nodes": []}, {"name": "model_6", "class_name": "Model", "config": {"name": "model_6", "layers": [{"name": "input_6", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_6"}, "inbound_nodes": []}, {"name": "sequential_1", "class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "batch_input_shape": [null, 128], "dtype": "float32", "units": 64000, "activation": "elu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Reshape", "config": {"name": "reshape_1", "trainable": true, "target_shape": [500, 128]}}, {"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "activation_2", "class_name": "Activation", "config": {"name": "activation_2", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"name": "conv1d_2", "class_name": "Conv1D", "config": {"name": "conv1d_2", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_2", 0, 0, {}]]]}, {"name": "add_1", "class_name": "Add", "config": {"name": "add_1", "trainable": true}, "inbound_nodes": [[["input_1", 0, 0, {}], ["conv1d_2", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["add_1", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_2", "layers": [{"name": "input_2", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_2"}, "inbound_nodes": []}, {"name": "activation_4", "class_name": "Activation", "config": {"name": "activation_4", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_2", 0, 0, {}]]]}, {"name": "conv1d_4", "class_name": "Conv1D", "config": {"name": "conv1d_4", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_4", 0, 0, {}]]]}, {"name": "add_2", "class_name": "Add", "config": {"name": "add_2", "trainable": true}, "inbound_nodes": [[["input_2", 0, 0, {}], ["conv1d_4", 0, 0, {}]]]}], "input_layers": [["input_2", 0, 0]], "output_layers": [["add_2", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_3", "layers": [{"name": "input_3", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_3"}, "inbound_nodes": []}, {"name": "activation_6", "class_name": "Activation", "config": {"name": "activation_6", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_3", 0, 0, {}]]]}, {"name": "conv1d_6", "class_name": "Conv1D", "config": {"name": "conv1d_6", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_6", 0, 0, {}]]]}, {"name": "add_3", "class_name": "Add", "config": {"name": "add_3", "trainable": true}, "inbound_nodes": [[["input_3", 0, 0, {}], ["conv1d_6", 0, 0, {}]]]}], "input_layers": [["input_3", 0, 0]], "output_layers": [["add_3", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_4", "layers": [{"name": "input_4", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_4"}, "inbound_nodes": []}, {"name": "activation_8", "class_name": "Activation", "config": {"name": "activation_8", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_4", 0, 0, {}]]]}, {"name": "conv1d_8", "class_name": "Conv1D", "config": {"name": "conv1d_8", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_8", 0, 0, {}]]]}, {"name": "add_4", "class_name": "Add", "config": {"name": "add_4", "trainable": true}, "inbound_nodes": [[["input_4", 0, 0, {}], ["conv1d_8", 0, 0, {}]]]}], "input_layers": [["input_4", 0, 0]], "output_layers": [["add_4", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_5", "layers": [{"name": "input_5", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_5"}, "inbound_nodes": []}, {"name": "activation_10", "class_name": "Activation", "config": {"name": "activation_10", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_5", 0, 0, {}]]]}, {"name": "conv1d_10", "class_name": "Conv1D", "config": {"name": "conv1d_10", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_10", 0, 0, {}]]]}, {"name": "add_5", "class_name": "Add", "config": {"name": "add_5", "trainable": true}, "inbound_nodes": [[["input_5", 0, 0, {}], ["conv1d_10", 0, 0, {}]]]}], "input_layers": [["input_5", 0, 0]], "output_layers": [["add_5", 0, 0]]}}, {"class_name": "Conv1D", "config": {"name": "conv1d_11", "trainable": true, "filters": 4, "kernel_size": [1], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Activation", "config": {"name": "activation_11", "trainable": true, "activation": "softmax"}}]}, "inbound_nodes": [[["input_6", 0, 0, {}]]]}], "input_layers": [["input_6", 0, 0]], "output_layers": [["sequential_1", 1, 0]]}, "inbound_nodes": [[["input_15", 0, 0, {}]]]}, {"name": "model_12", "class_name": "Model", "config": {"name": "model_12", "layers": [{"name": "input_12", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_12"}, "inbound_nodes": []}, {"name": "sequential_2", "class_name": "Sequential", "config": {"name": "sequential_2", "layers": [{"class_name": "Conv1D", "config": {"name": "conv1d_12", "trainable": true, "batch_input_shape": [null, 500, 4], "dtype": "float32", "filters": 128, "kernel_size": [1], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Model", "config": {"name": "model_7", "layers": [{"name": "input_7", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_7"}, "inbound_nodes": []}, {"name": "activation_13", "class_name": "Activation", "config": {"name": "activation_13", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_7", 0, 0, {}]]]}, {"name": "conv1d_14", "class_name": "Conv1D", "config": {"name": "conv1d_14", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_13", 0, 0, {}]]]}, {"name": "add_6", "class_name": "Add", "config": {"name": "add_6", "trainable": true}, "inbound_nodes": [[["input_7", 0, 0, {}], ["conv1d_14", 0, 0, {}]]]}], "input_layers": [["input_7", 0, 0]], "output_layers": [["add_6", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_8", "layers": [{"name": "input_8", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_8"}, "inbound_nodes": []}, {"name": "activation_15", "class_name": "Activation", "config": {"name": "activation_15", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_8", 0, 0, {}]]]}, {"name": "conv1d_16", "class_name": "Conv1D", "config": {"name": "conv1d_16", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_15", 0, 0, {}]]]}, {"name": "add_7", "class_name": "Add", "config": {"name": "add_7", "trainable": true}, "inbound_nodes": [[["input_8", 0, 0, {}], ["conv1d_16", 0, 0, {}]]]}], "input_layers": [["input_8", 0, 0]], "output_layers": [["add_7", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_9", "layers": [{"name": "input_9", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_9"}, "inbound_nodes": []}, {"name": "activation_17", "class_name": "Activation", "config": {"name": "activation_17", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_9", 0, 0, {}]]]}, {"name": "conv1d_18", "class_name": "Conv1D", "config": {"name": "conv1d_18", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_17", 0, 0, {}]]]}, {"name": "add_8", "class_name": "Add", "config": {"name": "add_8", "trainable": true}, "inbound_nodes": [[["input_9", 0, 0, {}], ["conv1d_18", 0, 0, {}]]]}], "input_layers": [["input_9", 0, 0]], "output_layers": [["add_8", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_10", "layers": [{"name": "input_10", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_10"}, "inbound_nodes": []}, {"name": "activation_19", "class_name": "Activation", "config": {"name": "activation_19", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_10", 0, 0, {}]]]}, {"name": "conv1d_20", "class_name": "Conv1D", "config": {"name": "conv1d_20", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_19", 0, 0, {}]]]}, {"name": "add_9", "class_name": "Add", "config": {"name": "add_9", "trainable": true}, "inbound_nodes": [[["input_10", 0, 0, {}], ["conv1d_20", 0, 0, {}]]]}], "input_layers": [["input_10", 0, 0]], "output_layers": [["add_9", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_11", "layers": [{"name": "input_11", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_11"}, "inbound_nodes": []}, {"name": "activation_21", "class_name": "Activation", "config": {"name": "activation_21", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_11", 0, 0, {}]]]}, {"name": "conv1d_22", "class_name": "Conv1D", "config": {"name": "conv1d_22", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_21", 0, 0, {}]]]}, {"name": "add_10", "class_name": "Add", "config": {"name": "add_10", "trainable": true}, "inbound_nodes": [[["input_11", 0, 0, {}], ["conv1d_22", 0, 0, {}]]]}], "input_layers": [["input_11", 0, 0]], "output_layers": [["add_10", 0, 0]]}}, {"class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 1, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "inbound_nodes": [[["input_12", 0, 0, {}]]]}], "input_layers": [["input_12", 0, 0]], "output_layers": [["sequential_2", 1, 0]]}, "inbound_nodes": [[["model_6", 1, 0, {}]]]}], "input_layers": [["input_15", 0, 0]], "output_layers": [["model_12", 1, 0]]}, "keras_version": "2.2.4", "backend": "tensorflow"}
|
the_code/General/models/KC_GAN/KC_GAN_gen_iter210k_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8694f169e27c6c055ae69aa01efd2d8561d0f326acdf256927dbd0c580f7daa0
|
| 3 |
+
size 36598508
|
the_code/General/models/MEL_GAN/MEL_GAN_disc_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_13", "layers": [{"name": "input_14", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_14"}, "inbound_nodes": []}, {"name": "input_13", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_13"}, "inbound_nodes": []}, {"name": "model_6", "class_name": "Model", "config": {"name": "model_6", "layers": [{"name": "input_6", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_6"}, "inbound_nodes": []}, {"name": "sequential_1", "class_name": "Sequential", "config": [{"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "batch_input_shape": [null, 128], "dtype": "float32", "units": 64000, "activation": "elu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Reshape", "config": {"name": "reshape_1", "trainable": true, "target_shape": [500, 128]}}, {"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "activation_2", "class_name": "Activation", "config": {"name": "activation_2", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"name": "conv1d_2", "class_name": "Conv1D", "config": {"name": "conv1d_2", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_2", 0, 0, {}]]]}, {"name": "add_1", "class_name": "Add", "config": {"name": "add_1", "trainable": true}, "inbound_nodes": [[["input_1", 0, 0, {}], ["conv1d_2", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["add_1", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_2", "layers": [{"name": "input_2", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_2"}, "inbound_nodes": []}, {"name": "activation_4", "class_name": "Activation", "config": {"name": "activation_4", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_2", 0, 0, {}]]]}, {"name": "conv1d_4", "class_name": "Conv1D", "config": {"name": "conv1d_4", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_4", 0, 0, {}]]]}, {"name": "add_2", "class_name": "Add", "config": {"name": "add_2", "trainable": true}, "inbound_nodes": [[["input_2", 0, 0, {}], ["conv1d_4", 0, 0, {}]]]}], "input_layers": [["input_2", 0, 0]], "output_layers": [["add_2", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_3", "layers": [{"name": "input_3", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_3"}, "inbound_nodes": []}, {"name": "activation_6", "class_name": "Activation", "config": {"name": "activation_6", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_3", 0, 0, {}]]]}, {"name": "conv1d_6", "class_name": "Conv1D", "config": {"name": "conv1d_6", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_6", 0, 0, {}]]]}, {"name": "add_3", "class_name": "Add", "config": {"name": "add_3", "trainable": true}, "inbound_nodes": [[["input_3", 0, 0, {}], ["conv1d_6", 0, 0, {}]]]}], "input_layers": [["input_3", 0, 0]], "output_layers": [["add_3", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_4", "layers": [{"name": "input_4", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_4"}, "inbound_nodes": []}, {"name": "activation_8", "class_name": "Activation", "config": {"name": "activation_8", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_4", 0, 0, {}]]]}, {"name": "conv1d_8", "class_name": "Conv1D", "config": {"name": "conv1d_8", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_8", 0, 0, {}]]]}, {"name": "add_4", "class_name": "Add", "config": {"name": "add_4", "trainable": true}, "inbound_nodes": [[["input_4", 0, 0, {}], ["conv1d_8", 0, 0, {}]]]}], "input_layers": [["input_4", 0, 0]], "output_layers": [["add_4", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_5", "layers": [{"name": "input_5", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_5"}, "inbound_nodes": []}, {"name": "activation_10", "class_name": "Activation", "config": {"name": "activation_10", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_5", 0, 0, {}]]]}, {"name": "conv1d_10", "class_name": "Conv1D", "config": {"name": "conv1d_10", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_10", 0, 0, {}]]]}, {"name": "add_5", "class_name": "Add", "config": {"name": "add_5", "trainable": true}, "inbound_nodes": [[["input_5", 0, 0, {}], ["conv1d_10", 0, 0, {}]]]}], "input_layers": [["input_5", 0, 0]], "output_layers": [["add_5", 0, 0]]}}, {"class_name": "Conv1D", "config": {"name": "conv1d_11", "trainable": true, "filters": 4, "kernel_size": [1], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Activation", "config": {"name": "activation_11", "trainable": true, "activation": "softmax"}}], "inbound_nodes": [[["input_6", 0, 0, {}]]]}], "input_layers": [["input_6", 0, 0]], "output_layers": [["sequential_1", 1, 0]]}, "inbound_nodes": [[["input_14", 0, 0, {}]]]}, {"name": "random_weighted_average_1", "class_name": "RandomWeightedAverage", "config": {"name": "random_weighted_average_1", "trainable": true}, "inbound_nodes": [[["input_13", 0, 0, {}], ["model_6", 1, 0, {}]]]}, {"name": "model_12", "class_name": "Model", "config": {"name": "model_12", "layers": [{"name": "input_12", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_12"}, "inbound_nodes": []}, {"name": "sequential_2", "class_name": "Sequential", "config": [{"class_name": "Conv1D", "config": {"name": "conv1d_12", "trainable": true, "batch_input_shape": [null, 500, 4], "dtype": "float32", "filters": 128, "kernel_size": [1], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Model", "config": {"name": "model_7", "layers": [{"name": "input_7", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_7"}, "inbound_nodes": []}, {"name": "activation_13", "class_name": "Activation", "config": {"name": "activation_13", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_7", 0, 0, {}]]]}, {"name": "conv1d_14", "class_name": "Conv1D", "config": {"name": "conv1d_14", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_13", 0, 0, {}]]]}, {"name": "add_6", "class_name": "Add", "config": {"name": "add_6", "trainable": true}, "inbound_nodes": [[["input_7", 0, 0, {}], ["conv1d_14", 0, 0, {}]]]}], "input_layers": [["input_7", 0, 0]], "output_layers": [["add_6", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_8", "layers": [{"name": "input_8", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_8"}, "inbound_nodes": []}, {"name": "activation_15", "class_name": "Activation", "config": {"name": "activation_15", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_8", 0, 0, {}]]]}, {"name": "conv1d_16", "class_name": "Conv1D", "config": {"name": "conv1d_16", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_15", 0, 0, {}]]]}, {"name": "add_7", "class_name": "Add", "config": {"name": "add_7", "trainable": true}, "inbound_nodes": [[["input_8", 0, 0, {}], ["conv1d_16", 0, 0, {}]]]}], "input_layers": [["input_8", 0, 0]], "output_layers": [["add_7", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_9", "layers": [{"name": "input_9", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_9"}, "inbound_nodes": []}, {"name": "activation_17", "class_name": "Activation", "config": {"name": "activation_17", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_9", 0, 0, {}]]]}, {"name": "conv1d_18", "class_name": "Conv1D", "config": {"name": "conv1d_18", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_17", 0, 0, {}]]]}, {"name": "add_8", "class_name": "Add", "config": {"name": "add_8", "trainable": true}, "inbound_nodes": [[["input_9", 0, 0, {}], ["conv1d_18", 0, 0, {}]]]}], "input_layers": [["input_9", 0, 0]], "output_layers": [["add_8", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_10", "layers": [{"name": "input_10", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_10"}, "inbound_nodes": []}, {"name": "activation_19", "class_name": "Activation", "config": {"name": "activation_19", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_10", 0, 0, {}]]]}, {"name": "conv1d_20", "class_name": "Conv1D", "config": {"name": "conv1d_20", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_19", 0, 0, {}]]]}, {"name": "add_9", "class_name": "Add", "config": {"name": "add_9", "trainable": true}, "inbound_nodes": [[["input_10", 0, 0, {}], ["conv1d_20", 0, 0, {}]]]}], "input_layers": [["input_10", 0, 0]], "output_layers": [["add_9", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_11", "layers": [{"name": "input_11", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_11"}, "inbound_nodes": []}, {"name": "activation_21", "class_name": "Activation", "config": {"name": "activation_21", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_11", 0, 0, {}]]]}, {"name": "conv1d_22", "class_name": "Conv1D", "config": {"name": "conv1d_22", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_21", 0, 0, {}]]]}, {"name": "add_10", "class_name": "Add", "config": {"name": "add_10", "trainable": true}, "inbound_nodes": [[["input_11", 0, 0, {}], ["conv1d_22", 0, 0, {}]]]}], "input_layers": [["input_11", 0, 0]], "output_layers": [["add_10", 0, 0]]}}, {"class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true}}, {"class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 1, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}], "inbound_nodes": [[["input_12", 0, 0, {}]]]}], "input_layers": [["input_12", 0, 0]], "output_layers": [["sequential_2", 1, 0]]}, "inbound_nodes": [[["model_6", 1, 0, {}]], [["input_13", 0, 0, {}]], [["random_weighted_average_1", 0, 0, {}]]]}], "input_layers": [["input_13", 0, 0], ["input_14", 0, 0]], "output_layers": [["model_12", 2, 0], ["model_12", 1, 0], ["model_12", 3, 0]]}, "keras_version": "2.1.5", "backend": "tensorflow"}
|
the_code/General/models/MEL_GAN/MEL_GAN_disc_iter160k_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8e830f931c8ba9819bfc6c8681f05ca48aaad3ed96bad0d29f9ff02e1248730
|
| 3 |
+
size 36600388
|
the_code/General/models/MEL_GAN/MEL_GAN_gen_architecture.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"class_name": "Model", "config": {"name": "model_14", "layers": [{"name": "input_15", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_15"}, "inbound_nodes": []}, {"name": "model_6", "class_name": "Model", "config": {"name": "model_6", "layers": [{"name": "input_6", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 128], "dtype": "float32", "sparse": false, "name": "input_6"}, "inbound_nodes": []}, {"name": "sequential_1", "class_name": "Sequential", "config": [{"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "batch_input_shape": [null, 128], "dtype": "float32", "units": 64000, "activation": "elu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Reshape", "config": {"name": "reshape_1", "trainable": true, "target_shape": [500, 128]}}, {"class_name": "Model", "config": {"name": "model_1", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_1"}, "inbound_nodes": []}, {"name": "activation_2", "class_name": "Activation", "config": {"name": "activation_2", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"name": "conv1d_2", "class_name": "Conv1D", "config": {"name": "conv1d_2", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_2", 0, 0, {}]]]}, {"name": "add_1", "class_name": "Add", "config": {"name": "add_1", "trainable": true}, "inbound_nodes": [[["input_1", 0, 0, {}], ["conv1d_2", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["add_1", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_2", "layers": [{"name": "input_2", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_2"}, "inbound_nodes": []}, {"name": "activation_4", "class_name": "Activation", "config": {"name": "activation_4", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_2", 0, 0, {}]]]}, {"name": "conv1d_4", "class_name": "Conv1D", "config": {"name": "conv1d_4", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_4", 0, 0, {}]]]}, {"name": "add_2", "class_name": "Add", "config": {"name": "add_2", "trainable": true}, "inbound_nodes": [[["input_2", 0, 0, {}], ["conv1d_4", 0, 0, {}]]]}], "input_layers": [["input_2", 0, 0]], "output_layers": [["add_2", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_3", "layers": [{"name": "input_3", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_3"}, "inbound_nodes": []}, {"name": "activation_6", "class_name": "Activation", "config": {"name": "activation_6", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_3", 0, 0, {}]]]}, {"name": "conv1d_6", "class_name": "Conv1D", "config": {"name": "conv1d_6", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_6", 0, 0, {}]]]}, {"name": "add_3", "class_name": "Add", "config": {"name": "add_3", "trainable": true}, "inbound_nodes": [[["input_3", 0, 0, {}], ["conv1d_6", 0, 0, {}]]]}], "input_layers": [["input_3", 0, 0]], "output_layers": [["add_3", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_4", "layers": [{"name": "input_4", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_4"}, "inbound_nodes": []}, {"name": "activation_8", "class_name": "Activation", "config": {"name": "activation_8", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_4", 0, 0, {}]]]}, {"name": "conv1d_8", "class_name": "Conv1D", "config": {"name": "conv1d_8", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_8", 0, 0, {}]]]}, {"name": "add_4", "class_name": "Add", "config": {"name": "add_4", "trainable": true}, "inbound_nodes": [[["input_4", 0, 0, {}], ["conv1d_8", 0, 0, {}]]]}], "input_layers": [["input_4", 0, 0]], "output_layers": [["add_4", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_5", "layers": [{"name": "input_5", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_5"}, "inbound_nodes": []}, {"name": "activation_10", "class_name": "Activation", "config": {"name": "activation_10", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_5", 0, 0, {}]]]}, {"name": "conv1d_10", "class_name": "Conv1D", "config": {"name": "conv1d_10", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_10", 0, 0, {}]]]}, {"name": "add_5", "class_name": "Add", "config": {"name": "add_5", "trainable": true}, "inbound_nodes": [[["input_5", 0, 0, {}], ["conv1d_10", 0, 0, {}]]]}], "input_layers": [["input_5", 0, 0]], "output_layers": [["add_5", 0, 0]]}}, {"class_name": "Conv1D", "config": {"name": "conv1d_11", "trainable": true, "filters": 4, "kernel_size": [1], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Activation", "config": {"name": "activation_11", "trainable": true, "activation": "softmax"}}], "inbound_nodes": [[["input_6", 0, 0, {}]]]}], "input_layers": [["input_6", 0, 0]], "output_layers": [["sequential_1", 1, 0]]}, "inbound_nodes": [[["input_15", 0, 0, {}]]]}, {"name": "model_12", "class_name": "Model", "config": {"name": "model_12", "layers": [{"name": "input_12", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 4], "dtype": "float32", "sparse": false, "name": "input_12"}, "inbound_nodes": []}, {"name": "sequential_2", "class_name": "Sequential", "config": [{"class_name": "Conv1D", "config": {"name": "conv1d_12", "trainable": true, "batch_input_shape": [null, 500, 4], "dtype": "float32", "filters": 128, "kernel_size": [1], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Model", "config": {"name": "model_7", "layers": [{"name": "input_7", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_7"}, "inbound_nodes": []}, {"name": "activation_13", "class_name": "Activation", "config": {"name": "activation_13", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_7", 0, 0, {}]]]}, {"name": "conv1d_14", "class_name": "Conv1D", "config": {"name": "conv1d_14", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_13", 0, 0, {}]]]}, {"name": "add_6", "class_name": "Add", "config": {"name": "add_6", "trainable": true}, "inbound_nodes": [[["input_7", 0, 0, {}], ["conv1d_14", 0, 0, {}]]]}], "input_layers": [["input_7", 0, 0]], "output_layers": [["add_6", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_8", "layers": [{"name": "input_8", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_8"}, "inbound_nodes": []}, {"name": "activation_15", "class_name": "Activation", "config": {"name": "activation_15", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_8", 0, 0, {}]]]}, {"name": "conv1d_16", "class_name": "Conv1D", "config": {"name": "conv1d_16", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_15", 0, 0, {}]]]}, {"name": "add_7", "class_name": "Add", "config": {"name": "add_7", "trainable": true}, "inbound_nodes": [[["input_8", 0, 0, {}], ["conv1d_16", 0, 0, {}]]]}], "input_layers": [["input_8", 0, 0]], "output_layers": [["add_7", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_9", "layers": [{"name": "input_9", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_9"}, "inbound_nodes": []}, {"name": "activation_17", "class_name": "Activation", "config": {"name": "activation_17", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_9", 0, 0, {}]]]}, {"name": "conv1d_18", "class_name": "Conv1D", "config": {"name": "conv1d_18", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_17", 0, 0, {}]]]}, {"name": "add_8", "class_name": "Add", "config": {"name": "add_8", "trainable": true}, "inbound_nodes": [[["input_9", 0, 0, {}], ["conv1d_18", 0, 0, {}]]]}], "input_layers": [["input_9", 0, 0]], "output_layers": [["add_8", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_10", "layers": [{"name": "input_10", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_10"}, "inbound_nodes": []}, {"name": "activation_19", "class_name": "Activation", "config": {"name": "activation_19", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_10", 0, 0, {}]]]}, {"name": "conv1d_20", "class_name": "Conv1D", "config": {"name": "conv1d_20", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_19", 0, 0, {}]]]}, {"name": "add_9", "class_name": "Add", "config": {"name": "add_9", "trainable": true}, "inbound_nodes": [[["input_10", 0, 0, {}], ["conv1d_20", 0, 0, {}]]]}], "input_layers": [["input_10", 0, 0]], "output_layers": [["add_9", 0, 0]]}}, {"class_name": "Model", "config": {"name": "model_11", "layers": [{"name": "input_11", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 500, 128], "dtype": "float32", "sparse": false, "name": "input_11"}, "inbound_nodes": []}, {"name": "activation_21", "class_name": "Activation", "config": {"name": "activation_21", "trainable": true, "activation": "relu"}, "inbound_nodes": [[["input_11", 0, 0, {}]]]}, {"name": "conv1d_22", "class_name": "Conv1D", "config": {"name": "conv1d_22", "trainable": true, "filters": 128, "kernel_size": [5], "strides": [1], "padding": "same", "dilation_rate": [1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["activation_21", 0, 0, {}]]]}, {"name": "add_10", "class_name": "Add", "config": {"name": "add_10", "trainable": true}, "inbound_nodes": [[["input_11", 0, 0, {}], ["conv1d_22", 0, 0, {}]]]}], "input_layers": [["input_11", 0, 0]], "output_layers": [["add_10", 0, 0]]}}, {"class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true}}, {"class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 1, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}], "inbound_nodes": [[["input_12", 0, 0, {}]]]}], "input_layers": [["input_12", 0, 0]], "output_layers": [["sequential_2", 1, 0]]}, "inbound_nodes": [[["model_6", 1, 0, {}]]]}], "input_layers": [["input_15", 0, 0]], "output_layers": [["model_12", 1, 0]]}, "keras_version": "2.1.5", "backend": "tensorflow"}
|
the_code/General/models/MEL_GAN/MEL_GAN_gen_iter160k_weights.hdf5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:268a3ee2ea59e471127c990fdc8c71e3898789e777c5e2a6841118ab34a19958
|
| 3 |
+
size 36598508
|
the_code/General/output/testdata_motif_implant_100seqs.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9c9714546e46a68d980ab0f180d8719a71ed8f850ded5cb6c1d6145535910eb
|
| 3 |
+
size 3499451
|
the_code/General/output/testdata_sequence_evolution_10seqs.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dfdde021d10cc8869dc5b6f72ae82d60784d014730b5ec430c9d0dc7c7e6ee00
|
| 3 |
+
size 58025
|
the_code/General/utils.py
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import numpy as np
|
| 3 |
+
import matplotlib
|
| 4 |
+
|
| 5 |
+
def one_hot_encode_along_row_axis(sequence):
|
| 6 |
+
to_return = np.zeros((1, len(sequence), 4), dtype=np.int8)
|
| 7 |
+
seq_to_one_hot_fill_in_array(zeros_array=to_return[0], sequence=sequence, one_hot_axis=1)
|
| 8 |
+
return to_return
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def seq_to_one_hot_fill_in_array(zeros_array, sequence, one_hot_axis):
|
| 12 |
+
assert one_hot_axis == 0 or one_hot_axis == 1
|
| 13 |
+
if one_hot_axis == 0:
|
| 14 |
+
assert zeros_array.shape[1] == len(sequence)
|
| 15 |
+
elif one_hot_axis == 1:
|
| 16 |
+
assert zeros_array.shape[0] == len(sequence)
|
| 17 |
+
for (i, char) in enumerate(sequence):
|
| 18 |
+
if char == "A" or char == "a":
|
| 19 |
+
char_idx = 0
|
| 20 |
+
elif char == "C" or char == "c":
|
| 21 |
+
char_idx = 1
|
| 22 |
+
elif char == "G" or char == "g":
|
| 23 |
+
char_idx = 2
|
| 24 |
+
elif char == "T" or char == "t":
|
| 25 |
+
char_idx = 3
|
| 26 |
+
elif char == "N" or char == "n":
|
| 27 |
+
continue
|
| 28 |
+
else:
|
| 29 |
+
raise RuntimeError("Unsupported character: " + str(char))
|
| 30 |
+
if one_hot_axis == 0:
|
| 31 |
+
zeros_array[char_idx, i] = 1
|
| 32 |
+
elif one_hot_axis == 1:
|
| 33 |
+
zeros_array[i, char_idx] = 1
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def readfile(filename):
|
| 37 |
+
ids = []
|
| 38 |
+
ids_d = {}
|
| 39 |
+
seqs = {}
|
| 40 |
+
f = open(filename, 'r')
|
| 41 |
+
lines = f.readlines()
|
| 42 |
+
f.close()
|
| 43 |
+
seq = []
|
| 44 |
+
for line in lines:
|
| 45 |
+
if line[0] == '>':
|
| 46 |
+
ids.append(line[1:].rstrip('\n'))
|
| 47 |
+
id_line = line[1:].rstrip('\n').split('_')[0]
|
| 48 |
+
if id_line not in seqs:
|
| 49 |
+
seqs[id_line] = []
|
| 50 |
+
if id_line not in ids_d:
|
| 51 |
+
ids_d[id_line] = id_line
|
| 52 |
+
if seq:
|
| 53 |
+
seqs[ids[-2].split('_')[0]] = ("".join(seq))
|
| 54 |
+
seq = []
|
| 55 |
+
else:
|
| 56 |
+
seq.append(line.rstrip('\n').upper())
|
| 57 |
+
if seq:
|
| 58 |
+
seqs[ids[-1].split('_')[0]] = ("".join(seq))
|
| 59 |
+
|
| 60 |
+
return ids, ids_d, seqs
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def prepare_data(filename):
|
| 64 |
+
ids, ids_d, seqs, = readfile(filename)
|
| 65 |
+
X = np.array([one_hot_encode_along_row_axis(seqs[id_]) for id_ in ids_d]).squeeze(axis=1)
|
| 66 |
+
data = X
|
| 67 |
+
return data, ids
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def plot_prediction_givenax(model, fig, ntrack, track_no, seq_onehot):
|
| 71 |
+
NUM_CLASSES = model.output_shape[1]
|
| 72 |
+
real_score = model.predict(seq_onehot)[0]
|
| 73 |
+
ax = fig.add_subplot(ntrack, 2, track_no*2-1)
|
| 74 |
+
ax.margins(x=0)
|
| 75 |
+
ax.set_ylabel('Prediction', color='red')
|
| 76 |
+
ax.plot(real_score, '--', color='gray', linewidth=3)
|
| 77 |
+
ax.scatter(range(NUM_CLASSES), real_score, marker='o', color='red', linewidth=11)
|
| 78 |
+
ax.tick_params(axis='y', labelcolor='red')
|
| 79 |
+
ax.set_xticks(range(NUM_CLASSES),)
|
| 80 |
+
ax.set_xticklabels(range(1, NUM_CLASSES+1))
|
| 81 |
+
ax.grid(True)
|
| 82 |
+
return ax
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def create_saturation_mutagenesis_x(onehot):
|
| 86 |
+
mutagenesis_X = {"X":[],"ids":[]}
|
| 87 |
+
onehot = onehot.squeeze()
|
| 88 |
+
for mutloc,nt in enumerate(onehot):
|
| 89 |
+
new_X = np.copy(onehot)
|
| 90 |
+
if list(nt) == [1, 0, 0, 0]:
|
| 91 |
+
new_X[mutloc,:] = np.array([0, 1, 0, 0], dtype='int8')
|
| 92 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 93 |
+
new_X[mutloc,:] = np.array([0, 0, 1, 0], dtype='int8')
|
| 94 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 95 |
+
new_X[mutloc,:] = np.array([0, 0, 0, 1], dtype='int8')
|
| 96 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 97 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_C")
|
| 98 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_G")
|
| 99 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_T")
|
| 100 |
+
if list(nt) == [0, 1, 0, 0]:
|
| 101 |
+
new_X[mutloc,:] = np.array([1, 0, 0, 0], dtype='int8')
|
| 102 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 103 |
+
new_X[mutloc,:] = np.array([0, 0, 1, 0], dtype='int8')
|
| 104 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 105 |
+
new_X[mutloc,:] = np.array([0, 0, 0, 1], dtype='int8')
|
| 106 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 107 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_A")
|
| 108 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_G")
|
| 109 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_T")
|
| 110 |
+
if list(nt) == [0, 0, 1, 0]:
|
| 111 |
+
new_X[mutloc,:] = np.array([1, 0, 0, 0], dtype='int8')
|
| 112 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 113 |
+
new_X[mutloc,:] = np.array([0, 1, 0, 0], dtype='int8')
|
| 114 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 115 |
+
new_X[mutloc,:] = np.array([0, 0, 0, 1], dtype='int8')
|
| 116 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 117 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_A")
|
| 118 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_C")
|
| 119 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_T")
|
| 120 |
+
if list(nt) == [0, 0, 0, 1]:
|
| 121 |
+
new_X[mutloc,:] = np.array([1, 0, 0, 0], dtype='int8')
|
| 122 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 123 |
+
new_X[mutloc,:] = np.array([0, 1, 0, 0], dtype='int8')
|
| 124 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 125 |
+
new_X[mutloc,:] = np.array([0, 0, 1, 0], dtype='int8')
|
| 126 |
+
mutagenesis_X["X"].append(np.copy(new_X))
|
| 127 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_A")
|
| 128 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_C")
|
| 129 |
+
mutagenesis_X["ids"].append(str(mutloc)+"_G")
|
| 130 |
+
|
| 131 |
+
mutagenesis_X["X"] = np.array(mutagenesis_X["X"])
|
| 132 |
+
return mutagenesis_X
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def plot_mutagenesis_givenax(model, fig, ntrack, track_no, seq_onehot, class_no):
|
| 136 |
+
|
| 137 |
+
mutagenesis_X = create_saturation_mutagenesis_x(seq_onehot)
|
| 138 |
+
prediction_mutagenesis_X = model.predict(mutagenesis_X["X"])
|
| 139 |
+
original_prediction = model.predict(seq_onehot)
|
| 140 |
+
class_no = class_no-1
|
| 141 |
+
seq_shape = (seq_onehot.shape[1],seq_onehot.shape[2])
|
| 142 |
+
|
| 143 |
+
arr_a = np.zeros(seq_shape[0])
|
| 144 |
+
arr_c = np.zeros(seq_shape[0])
|
| 145 |
+
arr_g = np.zeros(seq_shape[0])
|
| 146 |
+
arr_t = np.zeros(seq_shape[0])
|
| 147 |
+
delta_pred = original_prediction[:,class_no] - prediction_mutagenesis_X[:,class_no]
|
| 148 |
+
for i,mut in enumerate(mutagenesis_X["ids"]):
|
| 149 |
+
if mut.endswith("A"):
|
| 150 |
+
arr_a[int(mut.split("_")[0])]=delta_pred[i]
|
| 151 |
+
if mut.endswith("C"):
|
| 152 |
+
arr_c[int(mut.split("_")[0])]=delta_pred[i]
|
| 153 |
+
if mut.endswith("G"):
|
| 154 |
+
arr_g[int(mut.split("_")[0])]=delta_pred[i]
|
| 155 |
+
if mut.endswith("T"):
|
| 156 |
+
arr_t[int(mut.split("_")[0])]=delta_pred[i]
|
| 157 |
+
|
| 158 |
+
arr_a[arr_a == 0] = None
|
| 159 |
+
arr_c[arr_c == 0] = None
|
| 160 |
+
arr_g[arr_g == 0] = None
|
| 161 |
+
arr_t[arr_t == 0] = None
|
| 162 |
+
|
| 163 |
+
ax = fig.add_subplot(ntrack, 1, track_no)
|
| 164 |
+
ax.set_ylabel('In silico\nMutagenesis')
|
| 165 |
+
ax.scatter(range(seq_shape[0]), -1*arr_a, label='A', color='green')
|
| 166 |
+
ax.scatter(range(seq_shape[0]), -1*arr_c, label='C', color='blue')
|
| 167 |
+
ax.scatter(range(seq_shape[0]), -1*arr_g, label='G', color='orange')
|
| 168 |
+
ax.scatter(range(seq_shape[0]), -1*arr_t, label='T', color='red')
|
| 169 |
+
ax.legend()
|
| 170 |
+
ax.axhline(y=0, linestyle='--', color='gray')
|
| 171 |
+
ax.set_xlim((0, seq_shape[0]))
|
| 172 |
+
_ = ax.set_xticks(np.arange(0, seq_shape[0]+1, 10))
|
| 173 |
+
|
| 174 |
+
return ax
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def insilico_evolution(regions, model, class_no, n_mutation):
|
| 178 |
+
#from scipy.stats import zscore
|
| 179 |
+
nuc_to_onehot = {"A":[1, 0, 0, 0],"C":[0, 1, 0, 0],"G":[0, 0, 1, 0],"T":[0, 0, 0, 1]}
|
| 180 |
+
mutation_pred = []
|
| 181 |
+
mutation_loc = []
|
| 182 |
+
print("Sequence index:",end=" ")
|
| 183 |
+
for id_ in range(len(regions)):
|
| 184 |
+
start_x = np.copy(regions[id_:id_+1])
|
| 185 |
+
pred = []
|
| 186 |
+
mut = []
|
| 187 |
+
for i in range(n_mutation):
|
| 188 |
+
mutagenesis_X = create_saturation_mutagenesis_x(start_x)
|
| 189 |
+
prediction_mutagenesis_X = model.predict(mutagenesis_X["X"])
|
| 190 |
+
original_prediction = model.predict(start_x)
|
| 191 |
+
## To use max z-score
|
| 192 |
+
# next_one = mutagenesis_X["ids"][np.argmax(zscore(prediction_mutagenesis_X-original_prediction,axis=1)[:,class_no-1])]
|
| 193 |
+
## To use max score
|
| 194 |
+
next_one = mutagenesis_X["ids"][np.argmax(prediction_mutagenesis_X[:,class_no-1]-original_prediction[:,class_no-1])]
|
| 195 |
+
pred.append(original_prediction)
|
| 196 |
+
mut.append(next_one)
|
| 197 |
+
start_x[0][int(next_one.split("_")[0]),:] = np.array(nuc_to_onehot[next_one.split("_")[1]], dtype='int8')
|
| 198 |
+
original_prediction = model.predict(start_x)
|
| 199 |
+
pred.append(original_prediction)
|
| 200 |
+
mutation_pred.append(pred)
|
| 201 |
+
mutation_loc.append(mut)
|
| 202 |
+
print(id_,end=",")
|
| 203 |
+
mutation_pred = np.array(mutation_pred).squeeze()
|
| 204 |
+
mutation_loc = np.array(mutation_loc)
|
| 205 |
+
return mutation_pred, mutation_loc
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def random_sequence_by_shuffling(seq_to_shuffle, number_of_random_regions):
|
| 209 |
+
seq_to_shuffle_onehot = one_hot_encode_along_row_axis(seq_to_shuffle)
|
| 210 |
+
shuffled_regions = []
|
| 211 |
+
for i in range(number_of_random_regions):
|
| 212 |
+
np.random.shuffle(seq_to_shuffle_onehot[0])
|
| 213 |
+
shuffled_regions.append(np.copy(seq_to_shuffle_onehot[0]))
|
| 214 |
+
shuffled_regions = np.array(shuffled_regions)
|
| 215 |
+
return shuffled_regions
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def random_sequence(seq_len, number_of_random_regions):
|
| 219 |
+
random_regions = []
|
| 220 |
+
for k in range(number_of_random_regions):
|
| 221 |
+
seq = []
|
| 222 |
+
for i in range(seq_len):
|
| 223 |
+
seq.append(np.random.choice(["A","C","G","T"]))
|
| 224 |
+
random_regions.append(one_hot_encode_along_row_axis("".join(seq)).squeeze())
|
| 225 |
+
random_regions = np.array(random_regions)
|
| 226 |
+
return random_regions
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def random_sequence_gc_adjusted(seq_len, number_of_random_regions, path_to_use_GC_content):
|
| 230 |
+
regions_to_use_GC = prepare_data(path_to_use_GC_content)
|
| 231 |
+
ACGT_dist = np.sum(regions_to_use_GC[0],axis=0)/len(regions_to_use_GC[0])
|
| 232 |
+
random_regions = []
|
| 233 |
+
for k in range(number_of_random_regions):
|
| 234 |
+
seq = []
|
| 235 |
+
for i in range(seq_len):
|
| 236 |
+
seq.append(np.random.choice(["A","C","G","T"],p=list(ACGT_dist[i])))
|
| 237 |
+
random_regions.append(one_hot_encode_along_row_axis("".join(seq)).squeeze())
|
| 238 |
+
random_regions = np.array(random_regions)
|
| 239 |
+
return random_regions
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def plot_deepexplainer_givenax(explainer, fig, ntrack, track_no, seq_onehot):
|
| 243 |
+
shap_values_ = explainer.shap_values(seq_onehot,ranked_outputs=1,check_additivity=False)
|
| 244 |
+
_, ax1 = plot_weights(shap_values_[0]*seq_onehot,
|
| 245 |
+
fig, ntrack, 1, track_no,
|
| 246 |
+
title="", subticks_frequency=10, ylab="")
|
| 247 |
+
return ax1
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def load_model(path_json, path_hdf5):
|
| 251 |
+
model_json_file = open(path_json)
|
| 252 |
+
model_json = model_json_file.read()
|
| 253 |
+
model = tf.keras.models.model_from_json(model_json)
|
| 254 |
+
model.load_weights(path_hdf5)
|
| 255 |
+
return model
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def add_pattern_to_best_location(pattern, regions, model, class_no):
|
| 259 |
+
pattern_added_regions = np.zeros(regions.shape,dtype="int")
|
| 260 |
+
pattern_locations = np.zeros(regions.shape[0],dtype="int")
|
| 261 |
+
print("Sequence index:",end=" ")
|
| 262 |
+
for r, region in enumerate(regions):
|
| 263 |
+
tmp_array = np.zeros((regions.shape[1]-pattern.shape[1]+1,regions.shape[1],regions.shape[2]))
|
| 264 |
+
for nt in range(tmp_array.shape[0]):
|
| 265 |
+
tmp_array[nt] = np.copy(region)
|
| 266 |
+
tmp_array[nt,nt:nt+pattern.shape[1],:] = pattern[0]
|
| 267 |
+
prediction = model.predict(tmp_array)[:,class_no-1]
|
| 268 |
+
pattern_locations[r] = np.argmax(prediction)
|
| 269 |
+
pattern_added_regions[r] = tmp_array[pattern_locations[r]]
|
| 270 |
+
print(r,end=",")
|
| 271 |
+
print("")
|
| 272 |
+
return {"regions":pattern_added_regions, "locations":pattern_locations}
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def plot_a(ax, base, left_edge, height, color):
|
| 276 |
+
a_polygon_coords = [
|
| 277 |
+
np.array([
|
| 278 |
+
[0.0, 0.0],
|
| 279 |
+
[0.5, 1.0],
|
| 280 |
+
[0.5, 0.8],
|
| 281 |
+
[0.2, 0.0],
|
| 282 |
+
]),
|
| 283 |
+
np.array([
|
| 284 |
+
[1.0, 0.0],
|
| 285 |
+
[0.5, 1.0],
|
| 286 |
+
[0.5, 0.8],
|
| 287 |
+
[0.8, 0.0],
|
| 288 |
+
]),
|
| 289 |
+
np.array([
|
| 290 |
+
[0.225, 0.45],
|
| 291 |
+
[0.775, 0.45],
|
| 292 |
+
[0.85, 0.3],
|
| 293 |
+
[0.15, 0.3],
|
| 294 |
+
])
|
| 295 |
+
]
|
| 296 |
+
for polygon_coords in a_polygon_coords:
|
| 297 |
+
ax.add_patch(matplotlib.patches.Polygon((np.array([1, height])[None, :] * polygon_coords
|
| 298 |
+
+ np.array([left_edge, base])[None, :]),
|
| 299 |
+
facecolor=color, edgecolor=color))
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
def plot_c(ax, base, left_edge, height, color):
|
| 303 |
+
ax.add_patch(matplotlib.patches.Ellipse(xy=[left_edge + 0.65, base + 0.5 * height], width=1.3, height=height,
|
| 304 |
+
facecolor=color, edgecolor=color))
|
| 305 |
+
ax.add_patch(
|
| 306 |
+
matplotlib.patches.Ellipse(xy=[left_edge + 0.65, base + 0.5 * height], width=0.7 * 1.3, height=0.7 * height,
|
| 307 |
+
facecolor='white', edgecolor='white'))
|
| 308 |
+
ax.add_patch(matplotlib.patches.Rectangle(xy=[left_edge + 1, base], width=1.0, height=height,
|
| 309 |
+
facecolor='white', edgecolor='white', fill=True))
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
def plot_g(ax, base, left_edge, height, color):
|
| 313 |
+
ax.add_patch(matplotlib.patches.Ellipse(xy=[left_edge + 0.65, base + 0.5 * height], width=1.3, height=height,
|
| 314 |
+
facecolor=color, edgecolor=color))
|
| 315 |
+
ax.add_patch(
|
| 316 |
+
matplotlib.patches.Ellipse(xy=[left_edge + 0.65, base + 0.5 * height], width=0.7 * 1.3, height=0.7 * height,
|
| 317 |
+
facecolor='white', edgecolor='white'))
|
| 318 |
+
ax.add_patch(matplotlib.patches.Rectangle(xy=[left_edge + 1, base], width=1.0, height=height,
|
| 319 |
+
facecolor='white', edgecolor='white', fill=True))
|
| 320 |
+
ax.add_patch(
|
| 321 |
+
matplotlib.patches.Rectangle(xy=[left_edge + 0.825, base + 0.085 * height], width=0.174, height=0.415 * height,
|
| 322 |
+
facecolor=color, edgecolor=color, fill=True))
|
| 323 |
+
ax.add_patch(
|
| 324 |
+
matplotlib.patches.Rectangle(xy=[left_edge + 0.625, base + 0.35 * height], width=0.374, height=0.15 * height,
|
| 325 |
+
facecolor=color, edgecolor=color, fill=True))
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def plot_t(ax, base, left_edge, height, color):
|
| 329 |
+
ax.add_patch(matplotlib.patches.Rectangle(xy=[left_edge + 0.4, base],
|
| 330 |
+
width=0.2, height=height, facecolor=color, edgecolor=color, fill=True))
|
| 331 |
+
ax.add_patch(matplotlib.patches.Rectangle(xy=[left_edge, base + 0.8 * height],
|
| 332 |
+
width=1.0, height=0.2 * height, facecolor=color, edgecolor=color,
|
| 333 |
+
fill=True))
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
default_colors = {0: 'green', 1: 'blue', 2: 'orange', 3: 'red'}
|
| 337 |
+
default_plot_funcs = {0: plot_a, 1: plot_c, 2: plot_g, 3: plot_t}
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
def plot_weights_given_ax(ax, array,
|
| 341 |
+
height_padding_factor,
|
| 342 |
+
length_padding,
|
| 343 |
+
subticks_frequency,
|
| 344 |
+
highlight,
|
| 345 |
+
colors=default_colors,
|
| 346 |
+
plot_funcs=default_plot_funcs):
|
| 347 |
+
if len(array.shape) == 3:
|
| 348 |
+
array = np.squeeze(array)
|
| 349 |
+
assert len(array.shape) == 2, array.shape
|
| 350 |
+
if array.shape[0] == 4 and array.shape[1] != 4:
|
| 351 |
+
array = array.transpose(1, 0)
|
| 352 |
+
assert array.shape[1] == 4
|
| 353 |
+
max_pos_height = 0.0
|
| 354 |
+
min_neg_height = 0.0
|
| 355 |
+
heights_at_positions = []
|
| 356 |
+
depths_at_positions = []
|
| 357 |
+
for i in range(array.shape[0]):
|
| 358 |
+
acgt_vals = sorted(enumerate(array[i, :]), key=lambda x: abs(x[1]))
|
| 359 |
+
positive_height_so_far = 0.0
|
| 360 |
+
negative_height_so_far = 0.0
|
| 361 |
+
for letter in acgt_vals:
|
| 362 |
+
plot_func = plot_funcs[letter[0]]
|
| 363 |
+
color = colors[letter[0]]
|
| 364 |
+
if letter[1] > 0:
|
| 365 |
+
height_so_far = positive_height_so_far
|
| 366 |
+
positive_height_so_far += letter[1]
|
| 367 |
+
else:
|
| 368 |
+
height_so_far = negative_height_so_far
|
| 369 |
+
negative_height_so_far += letter[1]
|
| 370 |
+
plot_func(ax=ax, base=height_so_far, left_edge=i, height=letter[1], color=color)
|
| 371 |
+
max_pos_height = max(max_pos_height, positive_height_so_far)
|
| 372 |
+
min_neg_height = min(min_neg_height, negative_height_so_far)
|
| 373 |
+
heights_at_positions.append(positive_height_so_far)
|
| 374 |
+
depths_at_positions.append(negative_height_so_far)
|
| 375 |
+
|
| 376 |
+
for color in highlight:
|
| 377 |
+
for start_pos, end_pos in highlight[color]:
|
| 378 |
+
assert start_pos >= 0.0 and end_pos <= array.shape[0]
|
| 379 |
+
min_depth = np.min(depths_at_positions[start_pos:end_pos])
|
| 380 |
+
max_height = np.max(heights_at_positions[start_pos:end_pos])
|
| 381 |
+
ax.add_patch(
|
| 382 |
+
matplotlib.patches.Rectangle(xy=[start_pos, min_depth],
|
| 383 |
+
width=end_pos - start_pos,
|
| 384 |
+
height=max_height - min_depth,
|
| 385 |
+
edgecolor=color, fill=False))
|
| 386 |
+
|
| 387 |
+
ax.set_xlim(-length_padding, array.shape[0] + length_padding)
|
| 388 |
+
ax.xaxis.set_ticks(np.arange(0.0, array.shape[0] + 1, subticks_frequency))
|
| 389 |
+
height_padding = max(abs(min_neg_height) * (height_padding_factor),
|
| 390 |
+
abs(max_pos_height) * (height_padding_factor))
|
| 391 |
+
ax.set_ylim(min_neg_height - height_padding, max_pos_height + height_padding)
|
| 392 |
+
return ax
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
def plot_weights(array, fig, n, n1, n2, title='', ylab='',
|
| 396 |
+
height_padding_factor=0.2,
|
| 397 |
+
length_padding=1.0,
|
| 398 |
+
subticks_frequency=20,
|
| 399 |
+
colors=default_colors,
|
| 400 |
+
plot_funcs=default_plot_funcs,
|
| 401 |
+
highlight={}):
|
| 402 |
+
ax = fig.add_subplot(n, n1, n2)
|
| 403 |
+
ax.set_title(title)
|
| 404 |
+
ax.set_ylabel(ylab)
|
| 405 |
+
y = plot_weights_given_ax(ax=ax, array=array,
|
| 406 |
+
height_padding_factor=height_padding_factor,
|
| 407 |
+
length_padding=length_padding,
|
| 408 |
+
subticks_frequency=subticks_frequency,
|
| 409 |
+
colors=colors,
|
| 410 |
+
plot_funcs=plot_funcs,
|
| 411 |
+
highlight=highlight)
|
| 412 |
+
return fig, ax
|
the_code/General/wgan_gp.py
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Following links were used to prepare this script.
|
| 2 |
+
# https://github.com/keras-team/keras-contrib/blob/master/examples/improved_wgan.py
|
| 3 |
+
# https://github.com/igul222/improved_wgan_training
|
| 4 |
+
# https://arxiv.org/abs/1712.06148
|
| 5 |
+
|
| 6 |
+
from __future__ import print_function, division
|
| 7 |
+
import os
|
| 8 |
+
import errno
|
| 9 |
+
from keras.layers.merge import _Merge
|
| 10 |
+
from keras.layers import Input, Dense, Reshape, Flatten, add, Activation
|
| 11 |
+
from keras.layers.convolutional import Conv1D
|
| 12 |
+
from keras.models import Sequential, Model
|
| 13 |
+
from keras.optimizers import Adam
|
| 14 |
+
from functools import partial
|
| 15 |
+
import keras.backend as K
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
BATCH_SIZE = 128
|
| 20 |
+
ITERS = 400001
|
| 21 |
+
SEQ_LEN = 500
|
| 22 |
+
SEQ_DIM = 4
|
| 23 |
+
DIM = 128
|
| 24 |
+
CRITIC_ITERS = 10
|
| 25 |
+
LAMBDA = 1
|
| 26 |
+
loginterval = 1000
|
| 27 |
+
seqinterval = 10000
|
| 28 |
+
modelinterval = 10000
|
| 29 |
+
selectedmodel = 400000
|
| 30 |
+
suffix = "generated"
|
| 31 |
+
ngenerate = 10
|
| 32 |
+
outputdirc = "./output/"
|
| 33 |
+
fastafile = "./data/KC_regions.fa"
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
for file in [outputdirc,
|
| 37 |
+
os.path.join(outputdirc, 'models'),
|
| 38 |
+
os.path.join(outputdirc, 'samples_ACGT'),
|
| 39 |
+
os.path.join(outputdirc, 'samples_raw')]:
|
| 40 |
+
try:
|
| 41 |
+
os.makedirs(file)
|
| 42 |
+
except OSError as exc:
|
| 43 |
+
if exc.errno == errno.EEXIST:
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def readfile(filename):
|
| 48 |
+
ids = []
|
| 49 |
+
seqs = []
|
| 50 |
+
f = open(filename, 'r')
|
| 51 |
+
lines = f.readlines()
|
| 52 |
+
f.close()
|
| 53 |
+
seq = []
|
| 54 |
+
for line in lines:
|
| 55 |
+
if line[0] == '>':
|
| 56 |
+
ids.append(line[1:].rstrip('\n'))
|
| 57 |
+
if seq != []: seqs.append("".join(seq))
|
| 58 |
+
seq = []
|
| 59 |
+
else:
|
| 60 |
+
seq.append(line.rstrip('\n').upper())
|
| 61 |
+
if seq != []:
|
| 62 |
+
seqs.append("".join(seq))
|
| 63 |
+
|
| 64 |
+
return ids, seqs
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def one_hot_encode_along_row_axis(sequence):
|
| 68 |
+
to_return = np.zeros((1, len(sequence), 4), dtype=np.int8)
|
| 69 |
+
seq_to_one_hot_fill_in_array(zeros_array=to_return[0],
|
| 70 |
+
sequence=sequence, one_hot_axis=1)
|
| 71 |
+
return to_return
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def seq_to_one_hot_fill_in_array(zeros_array, sequence, one_hot_axis):
|
| 75 |
+
assert one_hot_axis == 0 or one_hot_axis == 1
|
| 76 |
+
if one_hot_axis == 0:
|
| 77 |
+
assert zeros_array.shape[1] == len(sequence)
|
| 78 |
+
elif one_hot_axis == 1:
|
| 79 |
+
assert zeros_array.shape[0] == len(sequence)
|
| 80 |
+
for (i, char) in enumerate(sequence):
|
| 81 |
+
if char == "A" or char == "a":
|
| 82 |
+
char_idx = 0
|
| 83 |
+
elif char == "C" or char == "c":
|
| 84 |
+
char_idx = 1
|
| 85 |
+
elif char == "G" or char == "g":
|
| 86 |
+
char_idx = 2
|
| 87 |
+
elif char == "T" or char == "t":
|
| 88 |
+
char_idx = 3
|
| 89 |
+
elif char == "N" or char == "n":
|
| 90 |
+
continue
|
| 91 |
+
else:
|
| 92 |
+
raise RuntimeError("Unsupported character: "+str(char))
|
| 93 |
+
if one_hot_axis == 0:
|
| 94 |
+
zeros_array[char_idx, i] = 1
|
| 95 |
+
elif one_hot_axis == 1:
|
| 96 |
+
zeros_array[i, char_idx] = 1
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class RandomWeightedAverage(_Merge):
|
| 100 |
+
"""Provides a (random) weighted average between real and generated image samples"""
|
| 101 |
+
def _merge_function(self, inputs):
|
| 102 |
+
alpha = K.random_uniform((BATCH_SIZE, 1, 1))
|
| 103 |
+
return (alpha * inputs[0]) + ((1 - alpha) * inputs[1])
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class WGANGP():
|
| 107 |
+
def __init__(self):
|
| 108 |
+
self.img_rows = SEQ_LEN
|
| 109 |
+
self.img_cols = SEQ_DIM
|
| 110 |
+
self.img_shape = (self.img_rows, self.img_cols)
|
| 111 |
+
self.latent_dim = DIM
|
| 112 |
+
|
| 113 |
+
# Following parameter and optimizer set as recommended in paper
|
| 114 |
+
self.n_critic = CRITIC_ITERS
|
| 115 |
+
optimizer = Adam(lr=1e-4, beta_1=0.5, beta_2=0.9)
|
| 116 |
+
|
| 117 |
+
# Build the generator and critic
|
| 118 |
+
self.generator = self.build_generator()
|
| 119 |
+
self.critic = self.build_critic()
|
| 120 |
+
|
| 121 |
+
# -------------------------------
|
| 122 |
+
# Construct Computational Graph
|
| 123 |
+
# for the Critic
|
| 124 |
+
# -------------------------------
|
| 125 |
+
|
| 126 |
+
# Freeze generator's layers while training critic
|
| 127 |
+
self.generator.trainable = False
|
| 128 |
+
|
| 129 |
+
# Image input (real sample)
|
| 130 |
+
real_img = Input(shape=self.img_shape)
|
| 131 |
+
|
| 132 |
+
# Noise input
|
| 133 |
+
z_disc = Input(shape=(DIM,))
|
| 134 |
+
# Generate image based of noise (fake sample)
|
| 135 |
+
fake_img = self.generator(z_disc)
|
| 136 |
+
|
| 137 |
+
# Discriminator determines validity of the real and fake images
|
| 138 |
+
fake = self.critic(fake_img)
|
| 139 |
+
valid = self.critic(real_img)
|
| 140 |
+
|
| 141 |
+
# Construct weighted average between real and fake images
|
| 142 |
+
interpolated_img = RandomWeightedAverage()([real_img, fake_img])
|
| 143 |
+
# Determine validity of weighted sample
|
| 144 |
+
validity_interpolated = self.critic(interpolated_img)
|
| 145 |
+
|
| 146 |
+
# Use Python partial to provide loss function with additional
|
| 147 |
+
# 'averaged_samples' argument
|
| 148 |
+
partial_gp_loss = partial(self.gradient_penalty_loss, averaged_samples=interpolated_img)
|
| 149 |
+
partial_gp_loss.__name__ = 'gradient_penalty' # Keras requires function names
|
| 150 |
+
|
| 151 |
+
self.critic_model = Model(inputs=[real_img, z_disc],
|
| 152 |
+
outputs=[valid, fake, validity_interpolated])
|
| 153 |
+
self.critic_model.compile(loss=[self.wasserstein_loss, self.wasserstein_loss, partial_gp_loss],
|
| 154 |
+
optimizer=optimizer,
|
| 155 |
+
loss_weights=[1, 1, 10])
|
| 156 |
+
|
| 157 |
+
# -------------------------------
|
| 158 |
+
# Construct Computational Graph
|
| 159 |
+
# for Generator
|
| 160 |
+
# -------------------------------
|
| 161 |
+
|
| 162 |
+
# For the generator we freeze the critic's layers
|
| 163 |
+
self.critic.trainable = False
|
| 164 |
+
self.generator.trainable = True
|
| 165 |
+
|
| 166 |
+
# Sampled noise for input to generator
|
| 167 |
+
z_gen = Input(shape=(DIM,))
|
| 168 |
+
# Generate images based of noise
|
| 169 |
+
img = self.generator(z_gen)
|
| 170 |
+
# Discriminator determines validity
|
| 171 |
+
valid = self.critic(img)
|
| 172 |
+
# Defines generator model
|
| 173 |
+
self.generator_model = Model(z_gen, valid)
|
| 174 |
+
self.generator_model.compile(loss=self.wasserstein_loss, optimizer=optimizer)
|
| 175 |
+
|
| 176 |
+
def gradient_penalty_loss(self, y_true, y_pred, averaged_samples):
|
| 177 |
+
"""
|
| 178 |
+
Computes gradient penalty based on prediction and weighted real / fake samples
|
| 179 |
+
"""
|
| 180 |
+
gradients = K.gradients(y_pred, averaged_samples)[0]
|
| 181 |
+
# compute the euclidean norm by squaring ...
|
| 182 |
+
gradients_sqr = K.square(gradients)
|
| 183 |
+
# ... summing over the rows ...
|
| 184 |
+
gradients_sqr_sum = K.sum(gradients_sqr,
|
| 185 |
+
axis=np.arange(1, len(gradients_sqr.shape)))
|
| 186 |
+
# ... and sqrt
|
| 187 |
+
gradient_l2_norm = K.sqrt(gradients_sqr_sum)
|
| 188 |
+
# compute lambda * (1 - ||grad||)^2 still for each single sample
|
| 189 |
+
gradient_penalty = LAMBDA * K.square(1 - gradient_l2_norm)
|
| 190 |
+
# return the mean as loss over all the batch samples
|
| 191 |
+
return K.mean(gradient_penalty)
|
| 192 |
+
|
| 193 |
+
def wasserstein_loss(self, y_true, y_pred):
|
| 194 |
+
return K.mean(y_true * y_pred)
|
| 195 |
+
|
| 196 |
+
def res_cnn(self):
|
| 197 |
+
input_tensor = Input(shape=(SEQ_LEN, DIM))
|
| 198 |
+
x = Activation('relu')(input_tensor)
|
| 199 |
+
x = Conv1D(DIM, 5, padding='same')(x)
|
| 200 |
+
output = add([input_tensor, x])
|
| 201 |
+
res_1d = Model(inputs=[input_tensor], outputs=[output])
|
| 202 |
+
return res_1d
|
| 203 |
+
|
| 204 |
+
def build_generator(self):
|
| 205 |
+
model = Sequential()
|
| 206 |
+
model.add(Dense(SEQ_LEN * DIM, activation='elu', input_shape=(DIM,)))
|
| 207 |
+
model.add(Reshape((SEQ_LEN, DIM)))
|
| 208 |
+
model.add(self.res_cnn())
|
| 209 |
+
model.add(self.res_cnn())
|
| 210 |
+
model.add(self.res_cnn())
|
| 211 |
+
model.add(self.res_cnn())
|
| 212 |
+
model.add(self.res_cnn())
|
| 213 |
+
model.add(Conv1D(SEQ_DIM, 1, padding='same'))
|
| 214 |
+
model.add(Activation('softmax'))
|
| 215 |
+
model.summary()
|
| 216 |
+
noise = Input(shape=(self.latent_dim,))
|
| 217 |
+
img = model(noise)
|
| 218 |
+
return Model(noise, img)
|
| 219 |
+
|
| 220 |
+
def build_critic(self):
|
| 221 |
+
model = Sequential()
|
| 222 |
+
model.add(Conv1D(DIM, 1, padding='same', input_shape=(SEQ_LEN, SEQ_DIM)))
|
| 223 |
+
model.add(self.res_cnn())
|
| 224 |
+
model.add(self.res_cnn())
|
| 225 |
+
model.add(self.res_cnn())
|
| 226 |
+
model.add(self.res_cnn())
|
| 227 |
+
model.add(self.res_cnn())
|
| 228 |
+
model.add(Flatten())
|
| 229 |
+
model.add(Dense(1))
|
| 230 |
+
model.summary()
|
| 231 |
+
img = Input(shape=self.img_shape)
|
| 232 |
+
validity = model(img)
|
| 233 |
+
return Model(img, validity)
|
| 234 |
+
|
| 235 |
+
def train(self, foldername, filename, epochs, batch_size,
|
| 236 |
+
log_interval=1000, seq_interval=10000, model_interval=10000):
|
| 237 |
+
|
| 238 |
+
ids, seqs = readfile(filename)
|
| 239 |
+
X_train = np.array([one_hot_encode_along_row_axis(seq) for seq in seqs]).squeeze(axis=1)
|
| 240 |
+
|
| 241 |
+
# Adversarial ground truths
|
| 242 |
+
valid = -np.ones((batch_size, 1))
|
| 243 |
+
fake = np.ones((batch_size, 1))
|
| 244 |
+
dummy = np.zeros((batch_size, 1))
|
| 245 |
+
|
| 246 |
+
disc_json = self.critic_model.to_json()
|
| 247 |
+
with open(foldername + '/disc.json', "w") as disc_json_file:
|
| 248 |
+
disc_json_file.write(disc_json)
|
| 249 |
+
|
| 250 |
+
gen_json = self.generator_model.to_json()
|
| 251 |
+
with open(foldername + '/gen.json', "w") as gen_json_file:
|
| 252 |
+
gen_json_file.write(gen_json)
|
| 253 |
+
|
| 254 |
+
d_loss_list = []
|
| 255 |
+
g_loss_list = []
|
| 256 |
+
for epoch in range(epochs):
|
| 257 |
+
for _ in range(self.n_critic):
|
| 258 |
+
# ---------------------
|
| 259 |
+
# Train Discriminator
|
| 260 |
+
# ---------------------
|
| 261 |
+
# Select a random batch of images
|
| 262 |
+
idx = np.random.randint(0, X_train.shape[0], batch_size)
|
| 263 |
+
imgs = X_train[idx]
|
| 264 |
+
# Sample generator input
|
| 265 |
+
noise = np.random.normal(0, 1, (batch_size, self.latent_dim))
|
| 266 |
+
# Train the critic
|
| 267 |
+
d_loss = self.critic_model.train_on_batch([imgs, noise],
|
| 268 |
+
[valid, fake, dummy])
|
| 269 |
+
# ---------------------
|
| 270 |
+
# Train Generator
|
| 271 |
+
# ---------------------
|
| 272 |
+
g_loss = self.generator_model.train_on_batch(noise, valid)
|
| 273 |
+
|
| 274 |
+
if epoch % log_interval == 0:
|
| 275 |
+
d_loss_list.append(d_loss)
|
| 276 |
+
g_loss_list.append(g_loss)
|
| 277 |
+
|
| 278 |
+
if epoch % seq_interval == 0:
|
| 279 |
+
samples = []
|
| 280 |
+
for i in range(1):
|
| 281 |
+
samples.extend(self.generate_samples())
|
| 282 |
+
with open(foldername + '/samples_ACGT/samples_ACGT_{}.fa'.format(epoch), 'w') as f:
|
| 283 |
+
for line_number, s in enumerate(samples[0]):
|
| 284 |
+
f.write(">" + str(line_number+1) + "\n")
|
| 285 |
+
s = "".join(s)
|
| 286 |
+
f.write(s + "\n")
|
| 287 |
+
with open((foldername + '/samples_raw/samples_{}.txt').format(epoch), 'w') as f2:
|
| 288 |
+
print(samples[1], file=f2)
|
| 289 |
+
|
| 290 |
+
if epoch % model_interval == 0:
|
| 291 |
+
self.critic_model.save_weights(foldername + '/models/disc_{}.hdf5'.format(epoch))
|
| 292 |
+
self.critic_model.save(foldername + '/models/disc_{}.h5'.format(epoch))
|
| 293 |
+
self.generator_model.save_weights(foldername + '/models/gen_{}.hdf5'.format(epoch))
|
| 294 |
+
self.generator_model.save(foldername + '/models/gen_{}.h5'.format(epoch))
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
import pickle
|
| 298 |
+
f = open(foldername + '/d_g_loss.pkl', "wb")
|
| 299 |
+
pickle.dump(d_loss_list,f)
|
| 300 |
+
pickle.dump(g_loss_list,f)
|
| 301 |
+
f.close()
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def generate_samples(self):
|
| 305 |
+
char_ACGT={0:'A' , 1:'C' , 2:'G' , 3:'T'}
|
| 306 |
+
noise = np.random.normal(0, 1, (BATCH_SIZE, self.latent_dim))
|
| 307 |
+
gen_imgs = self.generator.predict(noise)
|
| 308 |
+
samples = np.argmax(gen_imgs, axis=2)
|
| 309 |
+
decoded_samples = []
|
| 310 |
+
for i in range(len(samples)):
|
| 311 |
+
decoded = ''
|
| 312 |
+
for j in range(len(samples[i])):
|
| 313 |
+
decoded += char_ACGT[samples[i][j]]
|
| 314 |
+
decoded_samples.append(decoded)
|
| 315 |
+
return decoded_samples, gen_imgs
|
| 316 |
+
|
| 317 |
+
def generate(self, nb=1, model_number=0, result_number=0):
|
| 318 |
+
hdf5_filename = outputdirc + "/models/disc_" + str(model_number) + ".hdf5"
|
| 319 |
+
self.generator_model.load_weights(hdf5_filename)
|
| 320 |
+
samples = []
|
| 321 |
+
for i in range(nb):
|
| 322 |
+
samples.extend(self.generate_samples()[0])
|
| 323 |
+
with open(outputdirc + '/gen_seq/generated_{}_iter_{}.fa'.format(nb*BATCH_SIZE, model_number), 'w') as f:
|
| 324 |
+
counter = 0
|
| 325 |
+
for s in samples:
|
| 326 |
+
counter += 1
|
| 327 |
+
s = "".join(s)
|
| 328 |
+
f.write(">" + str(counter) + "_" + str(result_number) + "_" + str(model_number) + "\n" + s + "\n")
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
if __name__ == '__main__':
|
| 332 |
+
wgan = WGANGP()
|
| 333 |
+
# Train the model
|
| 334 |
+
wgan.train(outputdirc, fastafile, epochs=ITERS, batch_size=BATCH_SIZE,
|
| 335 |
+
log_interval=loginterval, seq_interval=seqinterval, model_interval=modelinterval)
|
| 336 |
+
|
| 337 |
+
# Generate sequences after training
|
| 338 |
+
try:
|
| 339 |
+
os.makedirs(os.path.join(outputdirc, 'gen_seq'))
|
| 340 |
+
except OSError as exc:
|
| 341 |
+
if exc.errno == errno.EEXIST:
|
| 342 |
+
pass
|
| 343 |
+
for i in range(0, selectedmodel+1, modelinterval):
|
| 344 |
+
wgan.generate(nb=ngenerate, model_number=i, result_number=suffix)
|