Skip to content
Snippets Groups Projects
Commit 29c1b0ff authored by shingjan's avatar shingjan
Browse files

better weight/bias dumping method

parent 77e2a231
No related branches found
No related tags found
No related merge requests found
......@@ -59,16 +59,10 @@ class WeightTensor(Tensor):
def dump_weight(self, file_name):
if len(self.input_data.shape) == 1:
dumpFcBias(file_name, self.input_data, self.input_data.shape[0])
dumpFcBias(file_name, self.input_data)
elif len(self.input_data.shape) == 2:
dumpFcWeights(file_name, self.input_data,
self.input_data.shape[0],
self.input_data.shape[1])
dumpFcWeights(file_name, self.input_data)
elif len(self.input_data.shape) == 4:
dumpConvWeights(file_name, self.input_data,
self.input_data.shape[0],
self.input_data.shape[1],
self.input_data.shape[2],
self.input_data.shape[3])
dumpConvWeights(file_name, self.input_data)
......@@ -84,14 +84,18 @@ def dumpData(file_name, X_test):
def dumpConvWeights(file_name, weights, N, C, H, W):
def dumpConvWeights(file_name, weights):
print (weights.shape)
print ("*DumpConvWeights")
print("-min_val = ", np.amin(weights))
print("-max_val = ", np.amax(weights))
N = weights.shape[0]
C = weights.shape[1]
H = weights.shape[2]
W = weights.shape[3]
f = open(file_name, "wb")
for i in range(N):
for j in range(C):
......@@ -103,14 +107,15 @@ def dumpConvWeights(file_name, weights, N, C, H, W):
def dumpFcWeights(file_name, weights, H, W):
def dumpFcWeights(file_name, weights):
print (weights.shape)
print ("*DumpFcWeights")
print("-min_val = ", np.amin(weights))
print("-max_val = ", np.amax(weights))
H = weights.shape[0]
W = weights.shape[1]
f = open(file_name, "wb")
for i in range(H):
for j in range(W):
......@@ -120,14 +125,14 @@ def dumpFcWeights(file_name, weights, H, W):
def dumpFcBias(file_name, bias, W):
def dumpFcBias(file_name, bias):
print (bias.shape)
print ("*DumpFcBias")
print("-min_val = ", np.amin(bias))
print("-max_val = ", np.amax(bias))
W = bias.shape[0]
f = open(file_name, "wb")
for i in range(W):
f.write(bias[i])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment