示例#1
0
        batch_size=32,
        dropout=1)
if select_case == 3:
    classifier = supervised_sAE(
        out_func='softmax',
        en_func='affine',  # encoder:[sigmoid] | [affine] 
        use_for='classification',
        loss_func=
        'mse',  # decoder:[sigmoid] with ‘cross_entropy’ | [affine] with ‘mse’
        ae_type='ae',  # ae | dae | sae
        noise_type='gs',  # Gaussian noise (gs) | Masking noise (mn)
        beta=0.6,  # 惩罚因子权重(KL项 | 非噪声样本项)
        p=0.01,  # DAE:样本该维作为噪声的概率 / SAE稀疏性参数:期望的隐层平均活跃度(在训练批次上取平均)
        sup_ae_struct=[x_dim, 200, 50, y_dim],
        sup_ae_epochs=100,
        ae_epochs=30,
        batch_size=32,
        ae_lr=1e-3,
        dropout=1)

Initializer.sess_init_all(sess)  # 初始化变量
summ = Summaries(os.path.basename(__file__), sess=sess)
classifier.train_model(X_train, Y_train, sess, summ)

# Test
print("[Test data...]")
Y_pred = classifier.test_model(X_test, Y_test, sess)

summ.train_writer.close()
sess.close()
                     dbn_struct=[dim, 100, 100, fault],
                     rbm_v_type='bin',
                     rbm_epochs=10,
                     batch_size=32,
                     cd_k=10,
                     rbm_lr=1e-3,
                     dropout=0.95)
if select_case == 2:
    classifier = CNN(output_act_func='softmax',
                     hidden_act_func='relu',
                     loss_fuc='cross_entropy',
                     use_for='classification',
                     cnn_lr=1e-3,
                     cnn_epochs=100,
                     img_shape=[dynamic, 52],
                     channels=[1, 6, 6, 64, fault],
                     fsize=[[4, 4], [3, 3]],
                     ksize=[[2, 2], [2, 2]],
                     batch_size=32,
                     dropout=0.9)

classifier.build_model()
classifier.train_model(X_train, Y_train, sess)

# Test
Y_pred = list()
print("[Test data...]")
for i in range(fault):
    print(">>>Test fault {}:".format(i))
    Y_pred.append(classifier.test_model(X_test[i], Y_test[i], sess))