我想创建一个与ASCII兼容的所有Qt文本代码的列表。也许我在这里使用了错误的术语,但是我的意思是那些值<128(前七个位)表示有效的ASCII字符。例如:UTF8可以,UTF16不能。
我想知道
O = [0.701733664614, 0.699495411782, 0.572129320819, 0.613315597684, 0.58079660603, 0.596638918579, 0.48453382119]
Ab = [datetime.datetime(2018, 12, 11, 14, 0), datetime.datetime(2018, 12, 21, 10, 0), datetime.datetime(2018, 12, 21, 14, 0), datetime.datetime(2019, 1, 1, 10, 0), datetime.datetime(2019, 1, 1, 14, 0), datetime.datetime(2019, 1, 11, 10, 0), datetime.datetime(2019, 1, 11, 14, 0)]
data = DataFrame(np.column_stack([O,Ab]),
columns=['ndvi', 'datetime'])
decade_end = len(data)-1
decade_begin = int(decade_end - len(data)*90/100)
data2 = data.loc[decade_begin:decade_end]
def load_data(time_series, train_perc, normalise_window,
decade_begin, decade_end, points=None):
data2 = time_series.loc[decade_begin:decade_end]
scaler = None
train = data2['ndvi'].values[0:-10].reshape(-1,1)
shift_steps = 1
train_targets = data2['ndvi'].shift(-shift_steps).values[0:-10].reshape(-1,1)
train_reshaped = train[:, 0].reshape(len(train), 1, 1)
x_train, y_train = train_reshaped, train_targets
x_test = data2['ndvi'].values[:-10].reshape(-1,1)
y_test = data2['ndvi'].values[-10:].reshape(-1,1)
return [x_train, y_train, scaler, x_test, y_test]
def build(layers):
model = Sequential()
model.add(LSTM(
input_shape=(int(layers[1]), int(layers[0])),
output_dim=int(layers[1]),
return_sequences=True))
model.add(Dropout(0.2))
model.add(Dense(
output_dim=layers[2]))
model.add(Activation("linear"))
model.compile(loss="mse", optimizer="rmsprop")
return model
X_train, y_train, scaler = load_data(data, 1, False,
decade_begin, decade_end, points=None)[0:3]
seq_len_in = len(X_train)
batch_size = 40
nb_hidden = int((2/3)*len(data))
model = build([1, seq_len_in, nb_hidden])
X_train, y_train, scaler = load_data(data, 1, False,
decade_begin, decade_end, points=None)[0:3]
model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=epochs,
validation_split=0.05, verbose=verbose, callbacks=
[lstm_progress(), TQDMCallback(outer_description="%-16s"%"Training LSTM",
show_inner=False)])
是否告诉我?参考:https://www.iana.org/assignments/character-sets/character-sets.xhtml
因此,我想从data
中排除那些不符合条件(兼容ASCII)的内容。知道如何最好地做到这一点吗?