" Using the CSNN simulator, by exporting the weights as binary files, using ***ExtractConnectionFile*** we can extract the weights as connection files to use as projections between the Populations on the SpiNNaker"
" w = np.fromfile(Input_File, dtype=np.dtype(np.float32))#[28, 28, 1, 400]\n",
" print(f'Input file shape = {w.shape}')\n",
" w=w.reshape(Connections_shape['x'], Connections_shape['y'], Connections_shape['z'])#x, y, z\n",
" w=np.array([w[:, :, i].transpose() for i in range(Connections_shape['z']) ])\n",
" w=w.reshape(Connections_shape['z'], Connections_shape['x']*Connections_shape['y']).transpose()# 400rows of 28*28 to 400 rows of 784 and then transposed==> 784*400\n",
" if n_samples_to_plot:\n",
" w_to_plot=[w.reshape(Connections_shape['x'], Connections_shape['y'],-1)[:,:,i] for i in range(n_samples_to_plot)]\n",
" w=w.reshape(Connections_shape['x']*Connections_shape['y'], Connections_shape['z'])# 400rows of 28*28 to 400 rows of 784 and then transposed==> 784*400\n",
" X,Y=w.shape\n",
" for x in range(X):\n",
" for y in range(Y):\n",
" if Non_Zero:\n",
" if w[x][y]:\n",
" line=f'{x} {y} {w[x][y]} 1\\n'\n",
" f.write(line)\n",
" extracted_weights.append(w[x][y])\n",
" else:\n",
" line=f'{x} {y} {w[x][y]} 1\\n' \n",
" f.write(line)\n",
" extracted_weights.append(w[x][y])\n",
" \n",
" f.close()\n",
" if n_samples_to_plot:\n",
" w_to_plot=[w.reshape(Connections_shape['x'], Connections_shape['y'],-1)[:,:,i] for i in range(n_samples_to_plot)]\n",
Using the CSNN simulator, by exporting the weights as binary files, using ***ExtractConnectionFile*** we can extract the weights as connection files to use as projections between the Populations on the SpiNNaker
w=w.reshape(Connections_shape['z'],Connections_shape['x']*Connections_shape['y']).transpose()# 400rows of 28*28 to 400 rows of 784 and then transposed==> 784*400