Beispiel #1
0
 def custom_plot(self, additional):
     for k in additional:
         if(k == Simulation.DISCRETIZE):
             for i in range(self.examples.noutputs):
                 for j in range(self.nbr_epoch):
                     if(self.plots['discretize_div'][i][j] != 0):
                         self.plots['discretize'][i][j] /= (self.plots['discretize_div'][i][j] * (self.nbDiscre ** self.nbDiscre))
             
             colors = [(0.2, 0.8, 0.88), 'b', 'g', 'r', 'c', 'm', 'y', 'k', (0.8, 0.1, 0.8), (0., 0.2, 0.5)]
     
             fig = plt.figure()
             ax = fig.add_subplot(111, projection='3d')
             for j in range(self.examples.noutputs):
                 ax.scatter([self.plots['discretize'][j][k] for k in self.plots['discretize_valid'][j]], [j] * 
                             len(self.plots['discretize_valid'][j]), self.plots['discretize_valid'][j], color=colors[j], marker='x')
         
             ax.set_xlabel('DISCRETIZED VALUE')
             ax.set_ylabel('SHAPE')
             ax.set_zlabel('EPOCH')
             
             path = "/tmp/pyplot.%s.%s.png" % (sys.argv[0], time.strftime("%m-%d-%H-%M-%S", time.localtime()))
             plt.savefig(path)
             plt.show()
             
             
             plt.title('Discretize hidden layer')
             plt.ylabel('DISCRETIZED VALUE')
             plt.xlabel("EPOCHS")
             for j in range(self.examples.noutputs):
                 plt.plot(self.plots['discretize_valid'][j], [self.plots['discretize'][j][k] 
                                                              for k in self.plots['discretize_valid'][j]], '.', color=colors[j])
             path = "/tmp/pyplot.%s.%s.png" % (sys.argv[0], time.strftime("%m-%d-%H-%M-%S", time.localtime()))
             try:
                 plt.savefig(path)
             except ValueError:
                 print('Cannot save discretize_cloud')
             try:
                 plt.show()
             except ValueError:
                 print('Cannot display discretize_cloud')
         elif(k == Simulation.PROTOTYPE):
             lplot = [[0. for _ in range(self.examples.ninputs)] for _ in range(self.examples.noutputs)]
             for network in self.networks:
                 for i in range(len(self.examples.inputs)):
                     network['FoN'].calc_output(self.examples.inputs[i])
                     network['SoN'].calc_output(network['FoN'].stateHiddenNeurons)
                     
                     im = index_max(self.examples.outputs[i])
                     
                     for j in range(self.examples.ninputs):
                         lplot[im][j] += network['SoN'].stateOutputNeurons[j]
             
             fig = plt.figure()
             plt.clf()
             for i in range(self.examples.noutputs):
                 rpr.show_repr(lplot[i], self.width, fig, 250 + i, i)
             path = "/tmp/pyplot.%s.%s.png" % (sys.argv[0], time.strftime("%m-%d-%H-%M-%S", time.localtime()))
             plt.savefig(path)
             plt.show()
Beispiel #2
0
 def prototypes(self):
     lplot = [[0. for _ in range(self.examples.ninputs)] for _ in range(self.examples.noutputs)]
     for i in range(self.examples.noutputs):
         for j in range(self.examples.ninputs):
             for k in range(len(self.examples.inputs)):
                 if(i == index_max(self.examples.outputs[k])):
                     lplot[i][j] += self.examples.inputs[k][j]
                 
     fig = plt.figure()
     plt.clf()
     for i in range(self.examples.noutputs):
         rpr.show_repr(lplot[i], 16, fig, 250 + i, i)
     path = "/tmp/pyplot.%s.%s.png" % (sys.argv[0], time.strftime("%m-%d-%H-%M-%S", time.localtime()))
     plt.savefig(path)
     plt.show()
Beispiel #3
0
    def prototypes(self):
        lplot = [[0. for _ in range(self.examples.ninputs)]
                 for _ in range(self.examples.noutputs)]
        for i in range(self.examples.noutputs):
            for j in range(self.examples.ninputs):
                for k in range(len(self.examples.inputs)):
                    if (i == index_max(self.examples.outputs[k])):
                        lplot[i][j] += self.examples.inputs[k][j]

        fig = plt.figure()
        plt.clf()
        for i in range(self.examples.noutputs):
            rpr.show_repr(lplot[i], 16, fig, 250 + i, i)
        path = "/tmp/pyplot.%s.%s.png" % (
            sys.argv[0], time.strftime("%m-%d-%H-%M-%S", time.localtime()))
        plt.savefig(path)
        plt.show()
Beispiel #4
0
    def custom_plot(self, additional):
        for k in additional:
            if (k == Simulation.DISCRETIZE):
                for i in range(self.examples.noutputs):
                    for j in range(self.nbr_epoch):
                        if (self.plots['discretize_div'][i][j] != 0):
                            self.plots['discretize'][i][j] /= (
                                self.plots['discretize_div'][i][j] *
                                (self.nbDiscre**self.nbDiscre))

                colors = [(0.2, 0.8, 0.88), 'b', 'g', 'r', 'c', 'm', 'y', 'k',
                          (0.8, 0.1, 0.8), (0., 0.2, 0.5)]

                fig = plt.figure()
                ax = fig.add_subplot(111, projection='3d')
                for j in range(self.examples.noutputs):
                    ax.scatter([
                        self.plots['discretize'][j][k]
                        for k in self.plots['discretize_valid'][j]
                    ], [j] * len(self.plots['discretize_valid'][j]),
                               self.plots['discretize_valid'][j],
                               color=colors[j],
                               marker='x')

                ax.set_xlabel('DISCRETIZED VALUE')
                ax.set_ylabel('SHAPE')
                ax.set_zlabel('EPOCH')

                path = "/tmp/pyplot.%s.%s.png" % (
                    sys.argv[0],
                    time.strftime("%m-%d-%H-%M-%S", time.localtime()))
                plt.savefig(path)
                plt.show()

                plt.title('Discretize hidden layer')
                plt.ylabel('DISCRETIZED VALUE')
                plt.xlabel("EPOCHS")
                for j in range(self.examples.noutputs):
                    plt.plot(self.plots['discretize_valid'][j], [
                        self.plots['discretize'][j][k]
                        for k in self.plots['discretize_valid'][j]
                    ],
                             '.',
                             color=colors[j])
                path = "/tmp/pyplot.%s.%s.png" % (
                    sys.argv[0],
                    time.strftime("%m-%d-%H-%M-%S", time.localtime()))
                try:
                    plt.savefig(path)
                except ValueError:
                    print('Cannot save discretize_cloud')
                try:
                    plt.show()
                except ValueError:
                    print('Cannot display discretize_cloud')
            elif (k == Simulation.PROTOTYPE):
                lplot = [[0. for _ in range(self.examples.ninputs)]
                         for _ in range(self.examples.noutputs)]
                for network in self.networks:
                    for i in range(len(self.examples.inputs)):
                        network['FoN'].calc_output(self.examples.inputs[i])
                        network['SoN'].calc_output(
                            network['FoN'].stateHiddenNeurons)

                        im = index_max(self.examples.outputs[i])

                        for j in range(self.examples.ninputs):
                            lplot[im][j] += network['SoN'].stateOutputNeurons[
                                j]

                fig = plt.figure()
                plt.clf()
                for i in range(self.examples.noutputs):
                    rpr.show_repr(lplot[i], self.width, fig, 250 + i, i)
                path = "/tmp/pyplot.%s.%s.png" % (
                    sys.argv[0],
                    time.strftime("%m-%d-%H-%M-%S", time.localtime()))
                plt.savefig(path)
                plt.show()