0

This is the code that I am using to generate random biases and storing it as a list of array. I have tried reading back the stored CSV file but the format is no longer a list of arrays. Can somebody tell me how I can retrieve back the baizes in the same format? I am not trying to sort the list, i just want to read back the CSV file and retain the original formatting. Thanks in advance!

import csv
import numpy as np

sizes = [784, 30, 10]
biases = [np.random.randn(y, 1) for y in sizes[1:]]
#weights = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])]
biasfile0 = open('C:/Users/Sharath Talikatte/Desktop/Neural 
                              Networks/bias0.csv', 'w', encoding='utf-8')
with biasfile0:
    writerb0 = csv.writer(biasfile0)
    writerb0.writerow(biases[0])

biasfile1 = open('C:/Users/Sharath Talikatte/Desktop/Neural 
                              Networks/bias1.csv', 'w', encoding='utf- 8')
with biasfile1:
    writerb1 = csv.writer(biasfile1)
    writerb1.writerow(biases[1])
  • Possible duplicate of [sort csv by column](https://stackoverflow.com/questions/2100353/sort-csv-by-column) – Syed Waqas Bukhary Mar 21 '18 at 13:11
  • I'm not trying to sort the data. I want to read back the csv file and retain the original format. Since the biases is a list of arrays, i am unable to read back the data as the same list of arrays. It would be helpful if you can give a work around for this problem. Thanks in advance! – Sharath Talikatte Mar 21 '18 at 13:41

0 Answers0