def patch_ceilometer(): """Add patches which are not merged to upstream Order of patches applied: ceilometer-poll-cpu-util.patch ceilometer-rates-always-zero.patch ceilometer-support-network-bytes.patch """ patchfile_list = [ 'ceilometer-poll-cpu-util.patch', 'ceilometer-rates-always-zero.patch', 'ceilometer-support-network-bytes.patch', ] for patch_file in patchfile_list: utils.patch(DIST_PACKAGES_DIR, patch_file, 1)
def patch_nova_conductor(): """Add patches which are not merged to upstream Order of patches applied: live-migration-vifmapping-controller.patch """ patchfile_list = [ # Change-Id: If0fb5d764011521916fbbe15224f524a220052f3 'live-migration-vifmapping-controller.patch', ] for patch_file in patchfile_list: utils.patch(utils.DIST_PACKAGES_DIR, patch_file, 1) # Restart related service utils.execute('service', 'nova-conductor', 'restart')
def createdData(X, label): for c in range(OUTPUT_CLASSES): PATCH, LABEL, TEST_PATCH, TRAIN_PATCH, TEST_LABEL, TRAIN_LABEL = [], [], [], [], [], [] for h in range(X.shape[1] - PATCH_SIZE + 1): for w in range(X.shape[2] - PATCH_SIZE + 1): gt = label[h, w] if (gt == c + 1): img = patch(X, PATCH_SIZE, h, w) PATCH.append(img) LABEL.append(gt - 1) # 打乱切片 shuffle(PATCH) # 划分测试集与训练集 split_size = int(len(PATCH) * TEST_FRAC) TEST_PATCH.extend(PATCH[:split_size]) # 0 ~ split_size TRAIN_PATCH.extend(PATCH[split_size:]) # split_size ~ len(class) TEST_LABEL.extend(LABEL[:split_size]) TRAIN_LABEL.extend(LABEL[split_size:]) # 写入文件夹 train_dict, test_dict = {}, {} train_dict["train_patches"] = TRAIN_PATCH train_dict["train_labels"] = TRAIN_LABEL file_name = "Training_class(%d).mat" % c scipy.io.savemat(os.path.join(NEW_DATA_PATH, file_name), train_dict) test_dict["testing_patches"] = TEST_PATCH test_dict["testing_labels"] = TEST_LABEL file_name = "Testing_class(%d).mat" % c scipy.io.savemat(os.path.join(NEW_DATA_PATH, file_name), test_dict)
def patch_compute_xenapi(): """Add patches which are not merged to upstream Order of patches applied: support-disable-image-cache.patch speed-up-config-drive.patch ovs-interim-bridge.patch neutron-security-group.patch """ patchfile_list = [ 'support-disable-image-cache.patch', 'speed-up-config-drive.patch', 'ovs-interim-bridge.patch', 'neutron-security-group.patch', ] for patch_file in patchfile_list: utils.patch(DIST_PACKAGES_DIR, patch_file, 1)
def patch_compute_xenapi(): """Add patches which are not merged to upstream Order of patches applied: support-disable-image-cache.patch speed-up-config-drive.patch ovs-interim-bridge.patch neutron-security-group.patch live-migration-iscsi.patch support-vif-hotplug.patch fix-rescue-vm.patch live-migration-vifmapping.patch """ patchfile_list = [ # Change-Id: I5ebff2c1f7534b06233a4d41d7f5f2e5e3b60b5a 'support-disable-image-cache.patch', # Change-Id: I359e17d6d5838f4028df0bd47e4825de420eb383 'speed-up-config-drive.patch', # Change-Id: I0cfc0284e1fcd1a6169d31a7ad410716037e5cc2 'ovs-interim-bridge.patch', # Change-Id: Id9b39aa86558a9f7099caedabd2d517bf8ad3d68 'neutron-security-group.patch', # Change-Id: I88d1d384ab7587c428e517d184258bb517dfb4ab 'live-migration-iscsi.patch', # Change-Id: I22f3fe52d07100592015007653c7f8c47c25d22c 'support-vif-hotplug.patch', # Change-Id: I32c66733330bc9877caea7e2a2290c02b3906708 'fix-rescue-vm.patch', # Change-Id: If0fb5d764011521916fbbe15224f524a220052f3 'live-migration-vifmapping.patch', # TODO(huanxie): below patch isn't merged into upstream yet, # it only affects XS7.1 and later # Change-Id: I31850b25e2f32eb65a00fbb824b08646c9ed340a 'assert_can_migrated.patch', ] for patch_file in patchfile_list: utils.patch(utils.DIST_PACKAGES_DIR, patch_file, 1)
def patch_neutron_ovs_agent(): """Apply neutron patch Add conntrack-tools patch to support conntrack in Dom0 """ utils.patch('/usr/bin', 'fix-xenapi-returncode.patch', 2)
import matplotlib.pyplot as plt import pickle import os from nda import log from nda.problems import LogisticRegression from nda.optimizers import * from nda.optimizers.utils import generate_mixing_matrix from nda.experiment_utils import run_exp import tikzplotlib import time from utils import patch patch() def plot_exp(exps, configs, filename, dim, n_agent, logx=False, logy=False): colors = ['k', 'r', 'g', 'b', 'c', 'm', 'y'] line_styles = ['-', '--', ':'] # log.info("Initial accuracy = " + str(p.accuracy(x_0))) results = [[exp.get_name()] + list(exp.get_metrics()) for exp in exps] with open(f"data/{filename}", 'wb') as f: pickle.dump(results, f) row_index = {'t': 1, 'comm_rounds': 0} column_index = {'f': 0}
outputs = np.zeros((data.shape[1], (data.shape[2]))) # 创建等尺寸的 0矩阵接收预测值 data = standartize(data) # 标准化 data = pad(data, 8) # 填充边框 与切片填充大小一致 # -----------生成网络模型--------------- logdir = "07-05_09-42-34" # 日志文件 NET_PARAMS_PATH = os.path.join(os.getcwd(), "log", logdir, "net_params.pkl") net_params = torch.load(NET_PARAMS_PATH) # 加载训练好的模型参数 cnn = Net() # 生成网络 cnn.load_state_dict(net_params) # 参数放进网络 if torch.cuda.is_available(): # 使用GPU cnn = cnn.cuda() # -----------将数据输入模型------------- for h in range(data.shape[1] - slice_size + 1): for w in range(data.shape[2] - slice_size + 1): img = patch(data, slice_size, h, w) img = np.expand_dims(img, axis=0) # 再增加一个维度(模型接受三维数据) img = torch.from_numpy(img).float() if torch.cuda.is_available(): img = img.cuda() output = cnn(img) _, predicted = torch.max(output.data, 1) outputs[h, w] = np.array(predicted.cpu())[0] # -----------将target保存为图片------------ pic_name = logdir + ".tif" SAVE_PATH = os.path.join(os.getcwd(), "predicted", pic_name) PIL.Image.fromarray(outputs).save(SAVE_PATH) # PIL.Image.fromarray(target_mat).save('D:/Code/test.tif')