Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issues#44 and add support for dropout layer #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dump_percepnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import torch
import sys
import rnn_train
from torch.nn import Sequential, GRU, Conv1d, Linear
from torch.nn import Sequential, GRU, Conv1d, Linear, Dropout
import numpy as np

def printVector(f, vector, name, dtype='float'):
Expand All @@ -53,7 +53,7 @@ def dump_sequential_module(self, f, name):
self[0].dump_data(f,name,activation)
Sequential.dump_data = dump_sequential_module

def dump_linear_module(self, f, name, activation):
def dump_linear_module(self, f, name, activation='LINEAR'):
print("printing layer " + name)
weight = self.weight
bias = self.bias
Expand Down Expand Up @@ -144,12 +144,13 @@ def dump_conv1d_module(self, f, name, activation):
f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "nnet_data.h"\n\n')

for name, module in model.named_children():
module.dump_data(f, name)
if "dropout" not in name:
module.dump_data(f, name)

f.write('extern const RNNModel percepnet_model_orig = {\n')
for name, module in model.named_children():
f.write(' &{},\n'.format(name))
f.write('};\n')

f.close()
print("done")
print("done")