Storing a list of arrays into a CSV file and retrieving it back in a different program

0 votes

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])
Jun 6, 2018 in Python by ariaholic
• 7,320 points
32 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
550 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 56,160 points
339 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 56,160 points
56 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 12,360 points
98 views
0 votes
1 answer
0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14 in Python by Junaid
26 views
0 votes
1 answer
0 votes
2 answers

Write a for loop that prints all elements of a list and their position in the list. a = [4,7,3,2,5,9]

a = [4,7,3,2,5,9] b = enumerate(a) for i in ...READ MORE

answered 4 days ago in Python by Kei Tee
35 views
0 votes
0 answers
+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,710 points
43 views