#python #keras #boost #lstm
#python #keras #повышение #lstm
Вопрос:
Могу ли я интегрировать слои LSTM «оболочкой» с AdaBoost или случайным лесом (scikit) способом, близким к этому?
import numpy as np
import pandas as pd
import xgboost as xgb
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dropout
from keras.layers.advanced_activations import PReLU
from keras.models import Sequential
from keras.utils import np_utils
import tensorflow as tf
from sklearn.preprocessing import StandardScaler
from keras.layers import Bidirectional
class LSTM_block(keras.layers.Layer):
def init__(self):
super(LSTMBlock, self).__init__()
self.lstm1 = tf.keras.Bidirectional(LSTM(50, activation='relu'), input_shape=(1, 1))
self.lstm2 = tf.keras.Dense(10)
self.lstm3 = compile(optimizer='adam', loss='mse')
def call(self, inputs):
x = self.lstm2(inputs)
return self.lstm2(x)
Ada_estimator = KerasRegressor(build_fn= simple_model, epochs=100,
batch_size=10, verbose=0)
lstm = LSTM_Block()
y = lstm(tf.ones(shape=(3, 64))) # The
boosted_ann = AdaBoostRegressor(base_estimator= ada_estimator)
linear_4 = boosted_ann
boosted_ann.fit(X_train, y_train)# scale data
boosted_ann.predict(rescaledX_Test)
Спасибо за любую помощь!