<jupyter_start><jupyter_text>CNN  看情況reshape<jupyter_code>cnn_x1 = cnn_x.reshape(cnn_x.shape[0],cnn_x.shape[1],1)
cnn_y1 = cnn_y.reshape(len(cnn_y), 1)
cnn_x1.ndim
cnn_y1.shape
import datetime
cnn_x_train = cnn_x1[indexes < datetime.datetime(2018,1,1)]
cnn_y_train = cnn_y1[indexes < datetime.datetime(2018,1,1)]
#import datetime
#cnn_x_train = cnn_x[indexes < datetime.datetime(2018,1,1)]
#cnn_y_train = cnn_y[indexes < datetime.datetime(2018,1,1)]
cnn_x_train
cnn_y.shape
cnn_x1[0].shape
import keras
import keras.layers as layers
from keras.models import Sequential
from keras.initializers import he_normal

#input_shape = cnn_x[0].shape
#time_period = 200
#num_classes = 1


model_m = Sequential()

model = keras.Sequential()

model.add(layers.Conv1D(filters=20, kernel_size=3, activation='relu', input_shape=cnn_x1[0].shape))
model.add(layers.AveragePooling1D(3))

model.add(layers.Conv1D(filters=20, kernel_size=3, activation='relu'))
model.add(layers.AveragePooling1D(3))
model.add(layers.Flatten())
model.add(layers.Dense(units=120, activation='relu'))
model.add(layers.Dense(units=84, activation='relu'))
model.add(layers.Dense(units=60, activation='relu'))
model.add(layers.Dense(units=48, activation='relu'))
model.add(layers.Dense(units=24, activation='relu'))
model.add(layers.Dense(units=1,))#activation = softmax))

adam = keras.optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.99, epsilon=None, decay=0.01, amsgrad=False)

model.compile(loss='mse',
                optimizer=adam, metrics=['accuracy'])

print(model.summary())
history = model.fit(cnn_x_train, cnn_y_train,
                    batch_size=5000,
                    epochs=50,
         
                    verbose=1,
                    validation_split=0.1,
                   )
cnn_x_train
cnn_y_train
cnn_x_train
import keras
import keras.layers as layers
from keras.models import Sequential
from keras.initializers import he_normal

input_shape = cnn_x[0].shape
time_period = 200
num_classes = 1


model_m = Sequential()

model = keras.Sequential()

model.add(layers.Conv1D(filters=10, kernel_size=20, activation='relu', input_shape=cnn_x1[0].shape))
model.add(layers.AveragePooling1D(3))

#model.add(layers.Conv1D(filters=20, kernel_size=20, activation='relu'))
#model.add(layers.AveragePooling1D(1))
model.add(layers.Flatten())
model.add(layers.Dense(units=120, activation='relu'))
model.add(layers.Dense(units=84, activation='relu'))
model.add(layers.Dense(units=1, ))#activation = 'softmax'))

adam = keras.optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.99, epsilon=None, decay=0.01, amsgrad=False)

model.compile(loss='mse',
                optimizer=adam, metrics=['accuracy'])

print(model.summary())

history = model.fit(cnn_x_train, cnn_y_train,
                    batch_size=200,
                    epochs=50,
                    verbose=1,
                    validation_split=0.1, )
q = dic['0015'].index
q[0]
dic
世界真理大全['為什麼魏擇壹會讓陳恩子生氣']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14565070802427513, 'fraction_numerical': 0.049224544841537425, 'mean_word_length': 4.806262230919765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '70236', 'license': 'MIT', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1159, 'n_words': 158, 'path': 'finlab/CNN_practice.ipynb', 'repo_name': 'DandyWei/finlab_course_ml', 'size': '2966'}