Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
clip
Tuple with min and max clip ranges for both the numerical gradients and the gradients
obtained from the TensorFlow graph
update_num_grad
If numerical gradients are used, they will be updated every update_num_grad iterations
no_info_val
Global or feature-wise value considered as containing no information
write_dir
Directory to write tensorboard files to
sess
Optional Tensorflow session that will be used if passed instead of creating or inferring one internally
"""
self.predict = predict
# check whether the model and the auto-encoder are Keras or TF models and get session
is_model, is_model_keras, model_sess = _check_keras_or_tf(predict)
is_ae, is_ae_keras, ae_sess = _check_keras_or_tf(ae_model)
# TODO: check ae and model are compatible
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
classes = self.sess.run(self.predict(tf.convert_to_tensor(np.zeros(shape), dtype=tf.float32))).shape[1]
else:
self.model = False
classes = self.predict(np.zeros(shape)).shape[1]
eps[1] it should be (1x nb of features)
clip
Tuple with min and max clip ranges for both the numerical gradients and the gradients
obtained from the TensorFlow graph
update_num_grad
If numerical gradients are used, they will be updated every update_num_grad iterations
write_dir
Directory to write tensorboard files to
sess
Optional Tensorflow session that will be used if passed instead of creating or inferring one internally
"""
self.predict = predict
# check whether the model, encoder and auto-encoder are Keras or TF models and get session
is_model, is_model_keras, model_sess = _check_keras_or_tf(predict)
is_ae, is_ae_keras, ae_sess = _check_keras_or_tf(ae_model)
is_enc, is_enc_keras, enc_sess = _check_keras_or_tf(enc_model)
# TODO: check ae, enc and model are all compatible
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
self.classes = self.predict.predict(np.zeros(shape)).shape[1] # type: ignore
else: # black-box model
self.model = False
self.classes = self.predict(np.zeros(shape)).shape[1]
Tuple with min and max clip ranges for both the numerical gradients and the gradients
obtained from the TensorFlow graph
update_num_grad
If numerical gradients are used, they will be updated every update_num_grad iterations
no_info_val
Global or feature-wise value considered as containing no information
write_dir
Directory to write tensorboard files to
sess
Optional Tensorflow session that will be used if passed instead of creating or inferring one internally
"""
self.predict = predict
# check whether the model and the auto-encoder are Keras or TF models and get session
is_model, is_model_keras, model_sess = _check_keras_or_tf(predict)
is_ae, is_ae_keras, ae_sess = _check_keras_or_tf(ae_model)
# TODO: check ae and model are compatible
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
classes = self.sess.run(self.predict(tf.convert_to_tensor(np.zeros(shape), dtype=tf.float32))).shape[1]
else:
self.model = False
classes = self.predict(np.zeros(shape)).shape[1]
self.mode = mode
clip
Tuple with min and max clip ranges for both the numerical gradients and the gradients
obtained from the TensorFlow graph
update_num_grad
If numerical gradients are used, they will be updated every update_num_grad iterations
write_dir
Directory to write tensorboard files to
sess
Optional Tensorflow session that will be used if passed instead of creating or inferring one internally
"""
self.predict = predict
# check whether the model, encoder and auto-encoder are Keras or TF models and get session
is_model, is_model_keras, model_sess = _check_keras_or_tf(predict)
is_ae, is_ae_keras, ae_sess = _check_keras_or_tf(ae_model)
is_enc, is_enc_keras, enc_sess = _check_keras_or_tf(enc_model)
# TODO: check ae, enc and model are all compatible
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
self.classes = self.predict.predict(np.zeros(shape)).shape[1] # type: ignore
else: # black-box model
self.model = False
self.classes = self.predict(np.zeros(shape)).shape[1]
if is_enc:
numpy arrays. For eps[0], the array dimension should be (1x nb of prediction categories) and for
eps[1] it should be (1x nb of features)
clip
Tuple with min and max clip ranges for both the numerical gradients and the gradients
obtained from the TensorFlow graph
update_num_grad
If numerical gradients are used, they will be updated every update_num_grad iterations
write_dir
Directory to write tensorboard files to
sess
Optional Tensorflow session that will be used if passed instead of creating or inferring one internally
"""
self.predict = predict
# check whether the model, encoder and auto-encoder are Keras or TF models and get session
is_model, is_model_keras, model_sess = _check_keras_or_tf(predict)
is_ae, is_ae_keras, ae_sess = _check_keras_or_tf(ae_model)
is_enc, is_enc_keras, enc_sess = _check_keras_or_tf(enc_model)
# TODO: check ae, enc and model are all compatible
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
self.classes = self.predict.predict(np.zeros(shape)).shape[1] # type: ignore
else: # black-box model
self.model = False
self.classes = self.predict(np.zeros(shape)).shape[1]
# options for the optimizer
self.max_iter = max_iter
self.lam_init = lam_init
self.tol = tol
self.max_lam_steps = max_lam_steps
self.early_stop = early_stop
self.eps = eps
self.init = init
self.feature_range = feature_range
self.target_proba_arr = target_proba * np.ones(self.batch_size)
self.debug = debug
# check if the passed object is a model and get session
is_model, is_keras, model_sess = _check_keras_or_tf(predict_fn)
# if session provided, use it
if isinstance(sess, tf.compat.v1.Session):
self.sess = sess
else:
self.sess = model_sess
if is_model: # Keras or TF model
self.model = True
self.predict_fn = predict_fn.predict # type: ignore # array function
self.predict_tn = predict_fn # tensor function
else: # black-box model
self.predict_fn = predict_fn
self.predict_tn = None
self.model = False