Esempio n. 1
0
    'stride': [1, 1],
    'padding': [2, 4],
    'activation_fn': ['ReLU', 'Tanh']
}
net_params_2 = {
    'filter': 2,
    'channel': [10, 1],
    'kernel_size': [3, 5],
    'stride': [1, 1],
    'padding': [2, 4],
    'activation_fn': ['ReLU6', 'Tanh']
}
model_1 = ModelFocusCNN((84, 84), net_params=net_params_1)
model_2 = ModelFocusCNN((84, 84), net_params=net_params_2)
model_boost = ModelFocusBoost(
    LinearCPD(np.pi / 4),
    model_1,
    model_2,
    train_flags=[True, False],
)

# parameters
print(model_boost.count_parameters())
ones = np.arange(model_boost.count_parameters())
model_boost.set_parameters(ones)
print(list(model_boost.parameters()))

# forward
out = model_boost.forward(torch.rand([100, 1, 84, 84]))
print(out, out.shape)
Esempio n. 2
0
     dataset = DatasetAtari(
         'BreakoutNoFrameskip-v4',  # atari game name
         actor,  # mock actor
         n_state=args.n_state,  # set max number of states
         save_path='results',  # save path for gym
         binarize=args.binarize,  # binarize image to 0 and 1
     )
 """
 Changepoint Detector
     - specify changepoint detector which fits the dynamic of the object
 """
 if args.champ:
     cpd = CHAMPDetector('premise->object', CHAMP_params)
 else:
     logger.info('using simple linear changepoint detector')
     cpd = LinearCPD(np.pi / 4.0)
 """
 Model Template & Constructor
 """
 model = ModelCollectionDAG()
 net_params = json.loads(open(args.net).read())
 if args.model_type == 'focus':
     train_model = ModelFocusCNN(
         image_shape=dataset.frame_shape,
         net_params=net_params,
         use_prior=args.prior,
         argmax_mode=args.argmax_mode,
     )
 elif args.model_type == 'attn':
     train_model = ModelAttentionCNN(
         image_shape=dataset.frame_shape,
Esempio n. 3
0
 def __init__(self, *micp_losses, **kwargs):
     self.micp_losses = list(micp_losses)
     self.agg_fn = kwargs.get('agg_fn', sum)
     self.cp_detector = kwargs.get('cp_detector', LinearCPD(np.pi / 4))