def quickPlot(lnp, sampler, p0, p1, p2): """ Generates a figure showing the data, the best fit and 3 sigmas intervals (if possible), and the residuals """ left = 0.125 width = 1.0 - 2 * 0.125 rect1 = [left, 0.34, width, 1.0 - 0.1 - 0.34] rect2 = [left, 0.1, width, 0.34 - 0.1] fig = figure.figure() ax0 = fig.add_axes(rect1) ax1 = fig.add_axes(rect2, sharex=ax0) plotData(lnp, ax=ax0, lw=2.0, label="Data", zorder=5, color="#ff0000") plotFit(lnp, p0, p1, p2, ax=ax0, zorder=0, lw=1, color="0.0") # plotCI(lnp, sampler, ax=ax0, zorder=-5, alpha=0.3) ax0.set_xlabel("X") ax0.set_ylabel("Y") l = ax0.legend(numpoints=1, scatterpoints=1) l.draw_frame(False) l.draggable(True) figure.setp(ax0.get_xticklabels(), visible=False) figure.theme(ax=ax0) ax0.yaxis.set_major_locator(figure.MaxNLocator(5, prune="lower")) plotResiduals(lnp, sampler, p0, p1, p2, ax=ax1) ax1.set_xlabel("X") ax1.set_ylabel("Residuals") figure.theme(ax=ax1) ax0.yaxis.set_major_locator(figure.MaxNLocator(4, prune="both")) return ax0, ax1
def __init__(self, amount = 1): self.screen = [[' '] * ( wight) for i in range(height)] self.active = False self.is_hard = False if amount >= 2: if amount > 2: self.is_hard = True self.active = True self.curr2 = figure() self.curr_color2 = 0 self.level2 = 0 self.killed2 = 0 self.scores2 = 0 self.screen2 = [[' '] * wight for i in range(height)] self.delete2 = [] self.scores = 0 self.level = 0 self.killed = 0 self.curr = figure() self.curr_color = 0 self.delete = []
def rotate(self, arg, screen = 1): #arg = {left, right} #a = sum(x) in current figure #b = sum(x) in new figure #c = sum(y) in current figure #d = sum(y) in new figure if screen == 2: self.swap() new_figure = figure() new_figure.coords = self.curr.coords a, b, c, d = 0, 0, 0, 0 #a, b, c, d = eval("new_figure." + arg + '()') a, b, c, d = getattr(new_figure, arg)() while a < b: new_figure.move('up') b -= 4 while a > b: new_figure.move('down') a -= 4 while c < d: new_figure.move('left') d -= 4 while c > d: new_figure.move('right') c -= 4 for i in range(len(new_figure.coords)): x, y = new_figure.coords[i] if x >= height or x < 0 or y >= wight or y < 0 or (self.screen[x][y] != ' ' and [x, y] not in self.curr.coords): del new_figure if screen == 2: self.swap() # print(1, end = '') return False for i in range(len(new_figure.coords)): self.screen[self.curr.coords[i][0]][self.curr.coords[i][1]] = ' ' for i in range(len(new_figure.coords)): self.screen[new_figure.coords[i][0]][new_figure.coords[i][1]] = ('#', self.curr_color) del self.curr self.curr = new_figure if screen == 2: self.swap() return True
from IsarMain import IsarMain from ParseObj import ParseObj import figure # from figure import figure1,figure2 # load rka file import scipy.io as sio # MATLAB 5.0 MAT-file rkafile = sio.loadmat("rkafile.mat") rkaArr = rkafile['a'] # rkafile = 0 # this is a 10000x11 array # IsarMain XX, YY, Th1, Ph1, ISAR_VVdB, ISAR_VHdB, ISAR_HVdB, ISAR_HHdB = IsarMain(rkaArr) # wavefront object read obj = ParseObj("../kepce.obj") # plot 1)graph and 2)object from top(do later) rd: int = 40 figure.figure(obj, XX, YY, rd, Th1, Ph1, ISAR_VVdB, ISAR_VHdB, ISAR_HVdB, ISAR_HHdB)
import os, sys, threading import curses, colored from time import clock, sleep, time from figure import figure monitor = curses.initscr() wight = 9 height = 23 invisible = 4 figures = [figure() for i in range(7)] figures[0].make([[0, 0], [0, 1], [0, 2], [0, 3]]) figures[1].make(([[0, 0], [0, 1], [0, 2], [1, 2]])) figures[2].make(([[0, 0], [0, 1], [0, 2], [1, 1]])) figures[3].make(([[0, 0], [0, 1], [1, 2], [1, 1]])) figures[4].make(([[0, 2], [0, 1], [1, 0], [1, 1]])) figures[5].make([[0, 0], [0, 1], [1, 1], [1, 0]]) figures[6].make(([[0, 0], [0, 1], [0, 2], [-1, 2]])) log = open('log.txt' , 'w') color = {} color[figures[0]] = 'light_yellow' color[figures[1]] = 'purpur' color[figures[2]] = 'dark_blue' color[figures[3]] = 'light_blue' color[figures[4]] = 'green' color[figures[5]] = 'red'
# Forward L1 = np.dot(x, w1) + b1[0] L1 = self.sigmoid(L1) L2 = np.dot(L1, w2) + b2[0] L2 = self.sigmoid(L2) return np.argmax(L2, axis=1) if __name__ == "__main__": x_data = np.loadtxt('./data/exam_x.txt') # data y_label = np.loadtxt('./data/exam_y.txt', dtype=int) # label # x_data = np.loadtxt('./data/iris_x.txt') # data # y_label = np.loadtxt('./data/iris_y.txt', dtype=int) # label config = dict() config['input_dim'] = 2 config['output_dim'] = 2 config['learning_rate'] = 0.01 config['nodes_num'] = 10 config['batch_size'] = 10 config['itrnum'] = 2000 NNmodel = NN(config) loss = NNmodel.model(x_data, y_label) # figure.lossfig(loss) figure.figure(x_data, y_label, predict=NNmodel.predict, loss=loss)
#weight_conv2d_3, bias_conv2d_3 = model.get_layer('conv2d_3').get_weights() #weight_conv2d_4, bias_conv2d_4 = model.get_layer('conv2d_4').get_weights() #weight_conv2d_5, bias_conv2d_5 = model.get_layer('conv2d_5').get_weights() plt.figure() p1, = plt.plot(train_process.history['loss']) p2, = plt.plot(train_process.history['val_loss']) plt.legend([p1, p2], ['train_loss', 'val_loss']) #val_process = model.evaluate(data_val, expect_val) #predict_result = model.predict(data_test, batch_size=data_test.shape[0], verbose=0) predict_result = model.predict(data_test, batch_size=data_val.shape[0], verbose=0) from sklearn.metrics import mean_absolute_error MAE_predict = mean_absolute_error(predict_result.flatten(), expect_test.flatten()) figure(data_test, 50, 'Data test') figure(predict_result, 50, 'Predict result') figure(expect_test, 50, 'Expect test') ''' ####################显示每一层神经层的输出############################ layer_outputs = [layer.output for layer in model.layers[:5]] activation_model = models.Model(inputs=model.input, outputs=layer_outputs) activations = activation_model.predict(data_test) ################################################################## ''' display('Project end. Good luck !!!')
data.trend_rule.update(season) # ルール数を記録 CIM.act_rule_num.append(data.trend_rule.rule_num) if cfg.SHOW_MODEL_DETAIL: print("") end = time.time() print("合計時間:" + str(end - start)) rs = cfg.LSTM_REFERENCE_STEPS + 1 rt = cfg.REVEAL_TREND # モデルの結果を出力 fg = figure("result/Research/research", 200, cfg.SPAN, data, CIM, reference_steps=rs, reveal_trend=rt) fg.savefig_result("PredictTrend") fg.savefig_ruleweight("TrendRuleW") fg.savefig_chosenrule("ChosenRule") fg.savefig_compare_prediction("ComparePrediction") fg.savefig_compare_prediction_ave("ComparePredictionAverage") fg.savefig_rule_num("RuleMoving") fg.save_config("config", cfg)