<jupyter_start><jupyter_text>(1) ResNet<jupyter_code>base_model = resnet(Input(X_train.shape[1:]))
base_model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['categorical_accuracy'])
base_model.summary()
from tensorflow.keras.utils import plot_model
plot_model(base_model, to_file='model.png')<jupyter_output><empty_output><jupyter_text>(4) Resnet RF-1<jupyter_code>base_1_model = resnet_1(Input(X_train.shape[1:]))
base_1_model.summary()
def sigmoidal_decay(e, start=0, end=100, lr_start=1e-3, lr_end=1e-5):
    if e < start:
        return lr_start
    elif e > end:
        return lr_end

    middle = (start + end) / 2
    s = lambda x: 1 / (1 + np.exp(-x))

    return s(13 * (-e + middle) / np.abs(end - start)) * np.abs(lr_start - lr_end) + lr_end

lr = LearningRateScheduler(lambda e: sigmoidal_decay(e, end=100))<jupyter_output><empty_output><jupyter_text>(1)resnet 10번 트레이닝<jupyter_code>for i in range(10):
    model = resnet(Input(X_train.shape[1:]))
    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['categorical_accuracy'])

    lr = LearningRateScheduler(lambda e: sigmoidal_decay(e, end=100))

    model_name = 'base'+ str(i)
    checkpoint="checkpoints-10times/"+model_name+'_'+"cp.h5"

    mc = ModelCheckpoint(checkpoint, monitor='val_categorical_accuracy',
                          verbose=True, save_best_only=True,
                          mode ='auto', period =1)

    TrainDataGen = MixupGenerator(X_train, 
                              Y_train, 
                              batch_size=64,
                              alpha=0.4)()

    history1 = model.fit_generator(TrainDataGen,
                                   validation_data = (X_val, Y_val),
                               epochs=100,
                               callbacks=[lr, mc],
                               steps_per_epoch=np.ceil(len(X_train)/64)
                              )

    scores = model.evaluate(X_test, Y_test, verbose=1)

    print('Test loss:', scores[0])
    print('Test accuracy:', scores[1])<jupyter_output><empty_output><jupyter_text>test acc<jupyter_code>for i in range(10):
    model_name = 'base'+ str(i)
    checkpoint="checkpoints-10times/"+model_name+'_'+"cp.h5"
    model.load_weights(checkpoint)

    scores_test = model.predict(X_test, verbose=1)
    y_pred_test = np.argmax(scores_test,axis=1)
    y_real = np.argmax(Y_test,axis=1)
    Overall_accuracy = np.sum(y_pred_test==dev_test_labels)/len(X_test)
    print('Test accuracy:', Overall_accuracy)<jupyter_output><empty_output><jupyter_text>(4) ResNet RF-1 10번 트레이닝<jupyter_code>for i in range(10):

    model = resnet_1(Input(X_train.shape[1:]))
    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['categorical_accuracy'])

    lr = LearningRateScheduler(lambda e: sigmoidal_decay(e, end=100))

    model_name = 'base_conv_rf1_'+str(i)
    checkpoint="checkpoints-10times/"+model_name+'_'+"cp.h5"

    mc = ModelCheckpoint(checkpoint, monitor='val_categorical_accuracy',
                          verbose=True, save_best_only=True,
                          mode ='auto', period =1)

    TrainDataGen = MixupGenerator(X_train, 
                              Y_train, 
                              batch_size=64,
                              alpha=0.4)()

    history1 = model.fit_generator(TrainDataGen,
                                   validation_data = (X_val, Y_val),
                               epochs=100,
                               callbacks=[lr, mc],
                               steps_per_epoch=np.ceil(len(X_train)/64)
                              )

    scores = model.evaluate(X_test, Y_test, verbose=1)

    print('Test loss:', scores[0])
    print('Test accuracy:', scores[1])
for i in range(10):
    model_name = 'base_conv_rf1_'+str(i)
    checkpoint="checkpoints-10times/"+model_name+'_'+"cp.h5"
    model.load_weights(checkpoint)

    scores_test = model.predict(X_test, verbose=1)
    y_pred_test = np.argmax(scores_test,axis=1)
    y_real = np.argmax(Y_test,axis=1)
    Overall_accuracy = np.sum(y_pred_test==dev_test_labels)/len(X_test)
    print('Test accuracy:', Overall_accuracy)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12735063080218995, 'fraction_numerical': 0.022851701975720066, 'mean_word_length': 2.7484388938447815, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '464736', 'license': 'MIT', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1449, 'n_words': 203, 'path': 'code/01,04. baseline.ipynb', 'repo_name': 'ikwak2/Paper_EfficientASC', 'size': '4201'}