two_fault=0) labels = torch.sum(labels * torch.Tensor([1, 2, 3, 4, 5, 6]), 1).long() labels = labels.detach().numpy() if args.model is None: inputs = inputs.detach().numpy() numpy2arff(inputs, labels, args.output, var_list, mode_list) elif 'encoder' in args.model: encoder2arff(inputs, labels, args.model, args.output, mode_list) else: feature2arff(inputs, labels, args.model, args.output, mode_list) if args.system == 'mt': step_len = 64 data_path = parentdir + '\\tank_systems\\data\\{}\\'.format( args.purpose) mana = mt_data_manager() mana.load_data(data_path) mana.add_noise(snr) var_list = mana.cfg.variables[0:11] mode_list = ['normal'] + mana.cfg.faults inputs, labels = mana.random_h_batch(batch=batch, step_num=64, prop=0.2, sample_rate=1.0) if args.model is None: numpy2arff(inputs, labels, args.output, var_list, mode_list) elif 'encoder' in args.model: encoder2arff(inputs, labels, args.model, args.output, mode_list) else: feature2arff(inputs, labels, args.model, args.output, mode_list)
inputs, 16, figname= 'bpsk\\importance_heat_map_between_feature_fault_of_LSTM') simple_net(important_vars, important_features, 'bpsk\\lstm_simple_net.gv', var_list=var_list, mode_list=mode_list) # BPSK if 'mt' in system: data_path = parentdir + '\\tank_systems\\data\\train\\' mana = mt_data_manager() mana.load_data(data_path) mana.add_noise(20) var_list = mana.cfg.variables mode_list = ['normal'] + mana.cfg.faults inputs, _ = mana.random_h_batch(batch=test_batch, step_num=64, prop=0.2, sample_rate=1.0) # CNN if 'cnn' in network: ann = 'mt_cnn_distill_(8, 16, 32, 64).cnn' ann = parentdir + '\\ann_diagnoser\\mt\\train\\20db\\{}\\'.format( args.index) + ann important_vars = heat_map_feature_input( ann, inputs, figname=
labels = labels.detach().numpy() batch, variable, step = inputs.shape inputs = inputs.transpose((0, 2, 1)) inputs = inputs.reshape((batch * step, variable)) labels = np.repeat(labels, step) inputs = pca_selection.transform(inputs) numpy2arff(inputs, labels, 'pca_test.arff', var_list, mode_list) if args.system == 'mt': step_len = 64 pca_selection = PCA_feature_selection(0.95) # train train_path = parentdir + '\\tank_systems\\data\\train\\' mana_train = mt_data_manager() mana_train.load_data(train_path) mana_train.add_noise(snr) mode_list = ['normal'] + mana_train.cfg.faults inputs, labels = mana_train.random_h_batch(batch=batch, step_num=64, prop=0.2, sample_rate=1.0) batch, variable, step = inputs.shape inputs = inputs.transpose((0, 2, 1)) inputs = inputs.reshape((batch * step, variable)) inputs = pca_selection.learn_from(inputs) _, fe_num = inputs.shape labels = np.repeat(labels, step) var_list = ['fe' + str(i) for i in range(fe_num)] numpy2arff(inputs, labels, 'pca_train.arff', var_list, mode_list) # test 1 test_path = parentdir + '\\tank_systems\\data\\test\\'