Category : optimization

I’m trying to use Bayesian Optimization to choose hyperparameters for my Keras LSTM model. I first defined the function that returns the accuracy metric (RMSE): def fit_with(lr,b_size,n_input,layer1_units,layer2_units,dropout_1,dropout_2): generator = TimeseriesGenerator(scaled_X_train, scaled_y_train, length=int(n_input), batch_size=int(b_size)) model = Sequential() model.add(Bidirectional(LSTM(units=int(layer1_units), activation=’relu’ ,return_sequences=True, dropout=dropout_1, recurrent_dropout=dropout_1), input_shape=(int(n_input),scaled_X_train.shape[1]))) model.add(Bidirectional(LSTM(units=int(layer2_units), activation=’relu’, return_sequences=False, dropout=dropout_2, recurrent_dropout=dropout_1))) model.add(Dense(1)) model.compile(optimizer=’adam’, loss=root_mean_squared_error, lr=lr) es = EarlyStopping(monitor=’loss’,min_delta=0.001,patience=5) model.fit(generator,epochs=20,shuffle=False, ..

Read more

I have a list A: A = [[‘512’, ‘102’] [‘410’, ‘105’] [‘820’, ‘520’]] And list B: B = [[‘510’, ‘490’, ‘512’, ‘912’] [‘512’, ‘108’, ‘102’, ‘520’ , ‘901’, ‘821’] [‘510’, ‘118’, ‘284’]] I would like to leave only these rows in list A, that all values of which are contained in at least one row ..

Read more

Supposed I have two functions as below: from scipy.optimize import minimize from scipy.optimize import LinearConstraint from scipy.optimize import NonlinearConstraint #Create CCI function def cci(x): monthly_fitted = [] for i in range(0, len(x) – 1): fitted_upper = (upper_array – (np.sqrt(x[-1]) * x[i])) / np.sqrt(1 – x[-1]) monthly_fitted.append(fitted_upper) monthly_fitted = np.vstack(monthly_fitted) #Fitted matrix cdf_monthly = [norm.cdf(monthly_fitted[0:, i]) ..

Read more

I am using scipy.optimize.minimize to minimize a function with l2 norm constraints and non-negative constraints on the computed variables. More specifically, I have tried con = ({‘type’: ‘ineq’, ‘fun’: lambda x: x}, {‘type’: ‘eq’, ‘fun’: lambda w: np.dot(w.T, w) – 1}) or con = {‘type’: ‘eq’, ‘fun’: lambda w: np.dot(w.T, w) – 1} bounds = ..

Read more