-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathdata_condition.py
More file actions
33 lines (27 loc) · 1.09 KB
/
data_condition.py
File metadata and controls
33 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import torch
from . import ConditionInterface
from ..label_tensor import LabelTensor
from ..graph import Graph
from ..utils import check_consistency
class DataConditionInterface(ConditionInterface):
"""
Condition for data. This condition must be used every
time a Unsupervised Loss is needed in the Solver. The conditionalvariable
can be passed as extra-input when the model learns a conditional
distribution
"""
__slots__ = ["input_points", "conditional_variables"]
condition_type = ['unsupervised']
def __init__(self, input_points, conditional_variables=None):
"""
TODO
"""
super().__init__()
self.input_points = input_points
self.conditional_variables = conditional_variables
def __setattr__(self, key, value):
if (key == 'input_points') or (key == 'conditional_variables'):
check_consistency(value, (LabelTensor, Graph, torch.Tensor))
DataConditionInterface.__dict__[key].__set__(self, value)
elif key in ('_problem', '_condition_type'):
super().__setattr__(key, value)