def fit_inverse_model(self):

        # Pre-processing
        self.pre_process()
        has_fit_e = has_fit_f = False
        # Fit change-point model for electricity consumption
        print('Fitting electricity model...')
        if (hasattr(self, "weather_electricity")):
            self.im_electricity = model.InverseModel(self.weather_electricity.v_T_C,
                                                     self.eui_daily_electricity,
                                                     'Electricity')
            has_fit_e = self.im_electricity.fit_model()
            if (has_fit_e):
                self.im_electricity.plot_IM(self)
        # Fit change-point model for fossil fuel consumption
        print('Fitting fossil fuel model...')
        if (hasattr(self, "weather_fossil_fuel")):
            self.im_fossil_fuel = model.InverseModel(self.weather_fossil_fuel.v_T_C,
                                                     self.eui_daily_fossil_fuel,
                                                     'Fossil Fuel')
            has_fit_f = self.im_fossil_fuel.fit_model()
            if (has_fit_f): self.im_fossil_fuel.plot_IM(self)
        return (has_fit_e or has_fit_f)
Beispiel #2
0
import conf

# Tensorboard logging
import tensorboard_logger as tboard
timestamp = str(round(time.time()))[-6:]
tb_dir = conf.DIR + "/runs/es_" + timestamp
tboard.configure(tb_dir, flush_secs=5)

# gym
env = gym.make("BreakoutDeterministic-v4")
conf.OUTPUT_NUM = env.action_space.n

# models and learning
encoder = model.Encoder()

inverse_model = model.InverseModel(encoder=encoder)
criterion = torch.nn.CrossEntropyLoss()
optimizer = torch.optim.Adadelta(
    inverse_model.parameters(),
    lr=0.1)  #torch.optim.Adam(inverse_model.parameters(), lr=0.001)

# buffer
memory = memory.MemoryBuffer(size=20000,
                             batch_size=8,
                             replace=True,
                             bias_prob=0.3)

curr_state = None
episode_i = 0

while True: