加载中 README.rst +8 −20 原始行号 差异行号 差异行 加载中 @@ -64,44 +64,32 @@ To construct a Donut model: with tf.variable_scope('model') as model_vs: model = Donut( h_for_p_x=Sequential([ K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), ]), h_for_q_z=Sequential([ K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), ]), x_dims=120, z_dims=5, ) To train the Donut model: To train the Donut model, and use a trained model for prediction: .. code-block:: python from donut import DonutTrainer from donut import DonutTrainer, DonutPredictor trainer = DonutTrainer(model=model, model_vs=model_vs) with tf.Session().as_default(): trainer.fit(train_values, train_labels, train_missing, mean, std) To use a trained Donut model for prediction: .. code-block:: python from donut import DonutPredictor predictor = DonutPredictor(model) with tf.Session().as_default(): # Remember to train the model before using the predictor, # or to restore the saved model. ... # Now we can use the predictor. with tf.Session().as_default(): trainer.fit(train_values, train_labels, train_missing, mean, std) test_score = predictor.get_score(test_values, test_missing) To save and restore a trained model: 加载中 donut/model.py +4 −0 原始行号 差异行号 差异行 加载中 @@ -147,6 +147,10 @@ class Donut(VarScopeObject): """ Get the reconstruction probability for `x` and `y`. The larger `reconstruction probability`, the less likely a point is anomaly. You may take the negative of the score, if you want something to directly indicate the severity of anomaly. Args: x (tf.Tensor): 2-D `float32` :class:`tf.Tensor`, the windows of KPI observations in a mini-batch. 加载中 donut/prediction.py +4 −0 原始行号 差异行号 差异行 加载中 @@ -95,6 +95,10 @@ class DonutPredictor(VarScopeObject): """ Get the `reconstruction probability` of specified KPI observations. The larger `reconstruction probability`, the less likely a point is anomaly. You may take the negative of the score, if you want something to directly indicate the severity of anomaly. Args: values (np.ndarray): 1-D float32 array, the KPI observations. missing (np.ndarray): 1-D int32 array, the indicator of missing 加载中 加载中
README.rst +8 −20 原始行号 差异行号 差异行 加载中 @@ -64,44 +64,32 @@ To construct a Donut model: with tf.variable_scope('model') as model_vs: model = Donut( h_for_p_x=Sequential([ K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), ]), h_for_q_z=Sequential([ K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), K.layers.Dense(100, W_regularizer=K.regularizers.l2(0.001), K.layers.Dense(100, kernel_regularizer=K.regularizers.l2(0.001), activation=tf.nn.relu), ]), x_dims=120, z_dims=5, ) To train the Donut model: To train the Donut model, and use a trained model for prediction: .. code-block:: python from donut import DonutTrainer from donut import DonutTrainer, DonutPredictor trainer = DonutTrainer(model=model, model_vs=model_vs) with tf.Session().as_default(): trainer.fit(train_values, train_labels, train_missing, mean, std) To use a trained Donut model for prediction: .. code-block:: python from donut import DonutPredictor predictor = DonutPredictor(model) with tf.Session().as_default(): # Remember to train the model before using the predictor, # or to restore the saved model. ... # Now we can use the predictor. with tf.Session().as_default(): trainer.fit(train_values, train_labels, train_missing, mean, std) test_score = predictor.get_score(test_values, test_missing) To save and restore a trained model: 加载中
donut/model.py +4 −0 原始行号 差异行号 差异行 加载中 @@ -147,6 +147,10 @@ class Donut(VarScopeObject): """ Get the reconstruction probability for `x` and `y`. The larger `reconstruction probability`, the less likely a point is anomaly. You may take the negative of the score, if you want something to directly indicate the severity of anomaly. Args: x (tf.Tensor): 2-D `float32` :class:`tf.Tensor`, the windows of KPI observations in a mini-batch. 加载中
donut/prediction.py +4 −0 原始行号 差异行号 差异行 加载中 @@ -95,6 +95,10 @@ class DonutPredictor(VarScopeObject): """ Get the `reconstruction probability` of specified KPI observations. The larger `reconstruction probability`, the less likely a point is anomaly. You may take the negative of the score, if you want something to directly indicate the severity of anomaly. Args: values (np.ndarray): 1-D float32 array, the KPI observations. missing (np.ndarray): 1-D int32 array, the indicator of missing 加载中