-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds second training set to train params of gaussian dist via spliting * adds cuda support for all algorithms * Run LSTMAD, Donut and DAGMM with NNAutoencoder on CUDA (#105) * Ignore device placement on ReEBM as well * Adapt LSTMED * Sort detector execution by framework * Closes #89 #91 #92 #93 #94 #95 #96
- Loading branch information
Showing
13 changed files
with
274 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ pandas | |
tqdm | ||
scipy>=0.14.0 | ||
scikit-learn>=0.19.1 | ||
tensorflow | ||
flake8 | ||
matplotlib | ||
progressbar2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import tensorflow as tf | ||
import torch | ||
from tensorflow.python.client import device_lib | ||
from torch.autograd import Variable | ||
|
||
|
||
class GPUWrapper: | ||
def __init__(self, gpu): | ||
self.gpu = gpu | ||
|
||
@property | ||
def tf_device(self): | ||
local_device_protos = device_lib.list_local_devices() | ||
gpus = [x.name for x in local_device_protos if x.device_type == 'GPU'] | ||
return tf.device(gpus[self.gpu] if gpus else '/cpu:0') | ||
|
||
@property | ||
def torch_device(self): | ||
return torch.device(f'cuda:{self.gpu}' if torch.cuda.is_available() else 'cpu') | ||
|
||
def to_var(self, x, **kwargs): | ||
"""PyTorch only: send Var to proper device.""" | ||
x = x.to(self.torch_device) | ||
return Variable(x, **kwargs) | ||
|
||
def to_device(self, model): | ||
"""PyTorch only: send Model to proper device.""" | ||
model.to(self.torch_device) |
Oops, something went wrong.