Skip to content

Commit

Permalink
changed to vae.metrics and pinned keras ---vae working
Browse files Browse the repository at this point in the history
  • Loading branch information
paulzierep committed Apr 19, 2023
1 parent 4daebb5 commit f93cc95
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
50 changes: 25 additions & 25 deletions DM.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 20 additions & 6 deletions DNN_models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ scipy
scikit-learn
matplotlib-base
psutil
keras
keras >= 2.3.0
tensorflow
h5py

0 comments on commit f93cc95

Please sign in to comment.