for physical_device in physical_devices: tf.config.experimental.set_memory_growth(physical_device, True) warnings.filterwarnings('ignore') os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ['CUDA_VISIBLE_DEVICES'] = '-1' #Parameters to select the LSTM architecture days_forecast = 1 semana = 2 n_LSTM_hidden_layers = 2 n_cells = 200 n_features = 5 dataM = DataManager(path="data/", filter_items=["pm25", "temperature", "wind"]) station82_pm25 = dataM.get_pm25("84") station82_t = dataM.get_temperature("82") station82_w = dataM.get_wind("82") n_size = 100 n_input_steps = 24 * 7 * semana n_output_steps = 24 * 3 data_pm25 = np.copy(station82_pm25.CONCENTRATION.values) data_t = np.copy(station82_t.Value.values) data_w = np.copy(station82_w.Value.values) ensembles_pm25 = dataM.generate_ensambles(data_pm25, 2.4, n_size) ensembles_t = dataM.generate_ensambles(data_t, 0.5, n_size) ensembles_w = dataM.generate_ensambles(data_w, 0.05, n_size) file_name = "m_Weeks_" + str(semana) + "_hidden_" + str(
mls = CnnMeteo(n_input_steps, n_features, n_output_steps, drop=True, n_LSTM_hidden_layers=n_LSTM_hidden_layers, n_cells=n_cells) csv_writer_1 = CsvWriter() csv_writer_2 = CsvWriter() csv_writer_3 = CsvWriter() for j in range(days_forecast): for station in range(len(stations_SIATA)): print(stations_SIATA[station]) station_pm25 = dataM.get_pm25(stations_SIATA[station]) station_t = dataM.get_temperature(stations_Meteo[station]) station_w = dataM.get_wind(stations_Meteo[station]) number_samples = min(len(station_t.Value.values), len(station_pm25.CONCENTRATION.values)) station_pm25 = station_pm25[0:number_samples] station_t = station_t[0:number_samples] station_w = station_w[0:number_samples] pre_processor = Combiner() X, y = pre_processor.combine( n_input_steps, n_output_steps, station_t.Value.values, station_w.Value.values, station_pm25.CONCENTRATION.values, station_t.Date.dt.dayofweek.values, station_t.Date.dt.hour.values, station_pm25.CONCENTRATION.values) # Create Model
import os import tensorflow as tf #Comment to run with GPU o Select CPU physical_devices = tf.config.experimental.list_physical_devices('GPU') for physical_device in physical_devices: tf.config.experimental.set_memory_growth(physical_device, True) os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ['CUDA_VISIBLE_DEVICES'] = '-1' #Get Raw Data #Only load pm5.csv by filter_items dataM = DataManager(path="data/", filter_items=["pm25"]) station3_pm25 = dataM.get_pm25("3") #pre-process data n_input_steps = 24 * 7 * 2 n_output_steps = 24 * 3 pre_processor = Combiner() datax, datay = pre_processor.combine(n_input_steps, n_output_steps, station3_pm25.CONCENTRATION.values) #Create Model n_train = 64 * 100 n_features = 1 X = datax[0:n_train, :] Y = datay[0:n_train, :] X = X.reshape((X.shape[0], X.shape[1], n_features)) cnnSiata = CnnSiata(n_input_steps, n_features, n_output_steps)