1
1
import unittest
2
+
2
3
import torch
3
4
from botorch .posteriors import GPyTorchPosterior
4
5
from botorch_community .models .np_regression import NeuralProcessModel
@@ -15,6 +16,7 @@ def initialize(self):
15
16
self .y_dim = 1
16
17
self .r_dim = 8
17
18
self .z_dim = 8
19
+ self .n_context = 20
18
20
self .model = NeuralProcessModel (
19
21
torch .rand (100 , self .x_dim ),
20
22
torch .rand (100 , self .y_dim ),
@@ -25,6 +27,7 @@ def initialize(self):
25
27
self .y_dim ,
26
28
self .r_dim ,
27
29
self .z_dim ,
30
+ self .n_context
28
31
)
29
32
30
33
def test_r_encoder (self ):
@@ -71,10 +74,7 @@ def test_KLD_gaussian(self):
71
74
72
75
def test_data_to_z_params (self ):
73
76
self .initialize ()
74
- mu , logvar = self .model .data_to_z_params (
75
- self .model .train_X ,
76
- self .model .train_Y
77
- )
77
+ mu , logvar = self .model .data_to_z_params (self .model .train_X , self .model .train_Y )
78
78
self .assertEqual (mu .shape , (self .z_dim ,))
79
79
self .assertEqual (logvar .shape , (self .z_dim ,))
80
80
self .assertTrue (torch .is_tensor (mu ))
@@ -88,7 +88,7 @@ def test_forward(self):
88
88
def test_random_split_context_target (self ):
89
89
self .initialize ()
90
90
x_c , y_c , x_t , y_t = self .model .random_split_context_target (
91
- self .model .train_X [:, 0 ], self .model .train_Y
91
+ self .model .train_X [:, 0 ], self .model .train_Y , self . model . n_context
92
92
)
93
93
self .assertEqual (x_c .shape [0 ], 20 )
94
94
self .assertEqual (y_c .shape [0 ], 20 )
0 commit comments