From f93cc954fe9d6ccef43daf54b51364db9420e3d3 Mon Sep 17 00:00:00 2001 From: paulzierep Date: Wed, 19 Apr 2023 13:26:23 +0200 Subject: [PATCH] changed to vae.metrics and pinned keras ---vae working --- DM.py | 50 ++++++++++++++++++++++++------------------------ DNN_models.py | 26 +++++++++++++++++++------ requirements.txt | 2 +- 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/DM.py b/DM.py index 98ed1c9..b5345dd 100755 --- a/DM.py +++ b/DM.py @@ -1,39 +1,39 @@ #!/usr/bin/env python # importing numpy, pandas, and matplotlib +import matplotlib import numpy as np import pandas as pd -import matplotlib -matplotlib.use('agg') -import matplotlib.pyplot as plt -# importing sklearn -from sklearn.model_selection import train_test_split -from sklearn.model_selection import StratifiedKFold -from sklearn.decomposition import PCA -from sklearn.random_projection import GaussianRandomProjection -from sklearn import cluster -from sklearn.model_selection import GridSearchCV -from sklearn.svm import SVC -from sklearn.ensemble import RandomForestClassifier -from sklearn.metrics import roc_auc_score -from sklearn.metrics import accuracy_score -from sklearn.metrics import precision_score -from sklearn.metrics import recall_score -from sklearn.metrics import f1_score +matplotlib.use('agg') +# importing util libraries +import datetime +import importlib +import math +import os +import time # importing keras import keras import keras.backend as K -from keras.wrappers.scikit_learn import KerasClassifier -from keras.callbacks import EarlyStopping, ModelCheckpoint, LambdaCallback +import matplotlib.pyplot as plt +from keras.callbacks import EarlyStopping, LambdaCallback, ModelCheckpoint from keras.models import Model, load_model +from keras.wrappers.scikit_learn import KerasClassifier +from sklearn import cluster +from sklearn.decomposition import PCA +from sklearn.ensemble import RandomForestClassifier +from sklearn.metrics import ( + accuracy_score, + f1_score, + precision_score, + recall_score, + roc_auc_score, +) -# importing util libraries -import datetime -import time -import math -import os -import importlib +# importing sklearn +from sklearn.model_selection import GridSearchCV, StratifiedKFold, train_test_split +from sklearn.random_projection import GaussianRandomProjection +from sklearn.svm import SVC # importing custom library import DNN_models diff --git a/DNN_models.py b/DNN_models.py index 48fb37b..aed535d 100644 --- a/DNN_models.py +++ b/DNN_models.py @@ -1,10 +1,24 @@ -from keras.models import Sequential, Model -from keras.layers import Dense, Dropout, Input, Lambda, Conv2D, Conv2DTranspose, MaxPool2D, UpSampling2D, Flatten, Reshape, Cropping2D -from keras import backend as K -from keras.losses import mse, binary_crossentropy import math + import numpy as np +from keras import backend as K +from keras.layers import ( + Conv2D, + Conv2DTranspose, + Cropping2D, + Dense, + Dropout, + Flatten, + Input, + Lambda, + MaxPool2D, + Reshape, + UpSampling2D, +) +from keras.losses import binary_crossentropy, mse +from keras.models import Model, Sequential + # create MLP model def mlp_model(input_dim, numHiddenLayers=3, numUnits=64, dropout_rate=0.5): @@ -257,9 +271,9 @@ def variational_AE(dims, act='relu', init='glorot_uniform', output_act = False, vae.compile(optimizer='adam', ) - vae.metrics_tensors.append(K.mean(reconstruction_loss)) + vae.metrics.append(K.mean(reconstruction_loss)) vae.metrics_names.append("recon_loss") - vae.metrics_tensors.append(K.mean(beta * kl_loss)) + vae.metrics.append(K.mean(beta * kl_loss)) vae.metrics_names.append("kl_loss") return vae, encoder, decoder diff --git a/requirements.txt b/requirements.txt index 24ec837..b602a9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ scipy scikit-learn matplotlib-base psutil -keras +keras >= 2.3.0 tensorflow h5py \ No newline at end of file