from matplotlib import pyplot as plt WEIGTHS = [ [ # L1 [0.7095146, -0.4351325, 0.38553882, 0.84955347, -0.8693629, 0.1586302, -0.16126093, 0.09219088], [-0.41895103, 1.0214638, -1.0607314, 0.32464203, 0.8418823, 0.01737848, 0.5317601, -0.624525], [-0.08075078, 0.14494987, 0.01327306, 0.8879888, 0.60206324, 0.75329006, 0.34316933, -0.61903083], [-0.5218736, -0.78134096, -0.28972188, 0.00756884, -0.78290594, -0.57819647, -0.7074082, -0.87057704], ], [ # L2 [0.36770403, -0.17659009, -0.04314173, -0.46864474, -0.37941265, -0.78606385, 0.11138931, 0.23097174], [-0.78046024, 0.13901198, 0.14361085, 0.36618456, 0.45330787, 0.24032554, 0.48950365, 0.30290592], [0.3979908, -0.45248222, 0.6259473, -0.45595396, -0.12066315, -0.4472755, 0.12998834, -0.596446], [0.5494289, -0.7894139, 0.3571782, -0.39789405, 0.5636705, -0.24661142, 0.4947537, -0.40108407], [-0.13859335, -0.81092286, -0.38011226, 0.73964316, 0.68990386, -0.2698564, 0.516593, 0.12246455], [0.40053025, -0.521815, 0.01378736, -0.30294785, 0.6543718, -0.8365823, 0.82281274, -0.47260976], [0.08249452, 0.30632392, 0.05794358, 0.2482118, 0.86367106, -0.13674814, 0.04789656, -0.55030185], [-0.32528356, -0.3143816, 0.09667788, -0.2127953, -0.5707757, -0.39799848, 0.30206403, 0.44481543] ], [ # L3 [0.5724262, 0.30391088], [0.5853241, -0.92324615], [0.3748752, 0.8088594], [-0.892384, -1.0522624], [-1.0270239, 0.07374455], [0.2170913, -0.550893], [-0.07271451, 0.8194236], [0.14661156, -0.62796086] ] ] BIAS = [ # L1 [0.01425434, -0.06219335, -0.0201127, -0.04791382, -0.04360008, -0.05311861, -0.01731363, -0.00014839], # L2 [0.03480967, 0.06208326, -0.01576317, -0.00037753, -0.03940378, 0.05157978, -0.02775403, 0.04540931], # L3 [0.03787775, -0.03655371], ] def relu(x): return x if x > 0 else 0 def sigm(x): ex = 2.7182818 ** x return ex / (ex + 1) def linr(x): return x def process(value): if value > 3 or value < 0: raise ValueError("Value not in between 0 and 3") onehot_mat = [ [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0], ] L0 = onehot_mat[value] L1 = [linr(sum([L0[j] * WEIGTHS[0][j][i] for j in range(len(L0))]) + BIAS[0][i]) for i in range(8)] L2 = [linr(sum([L1[j] * WEIGTHS[1][j][i] for j in range(len(L1))]) + BIAS[1][i]) for i in range(8)] L3 = [sigm(sum([L2[j] * WEIGTHS[2][j][i] for j in range(len(L2))]) + BIAS[2][i]) for i in range(2)] return L3 if __name__ == '__main__': plt.plot(*process(0), 'x') plt.plot(*process(1), 'x') plt.plot(*process(2), 'x') plt.plot(*process(3), 'x') plt.xlabel('Real') plt.ylabel('Imaginary') plt.xlim([0, 1]) plt.ylim([0, 1]) plt.grid() plt.show()