Skip to content

Commit c4dbea6

Browse files
author
Yusuke Sugomori
committed
DBN__destruct
1 parent 876e9ff commit c4dbea6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

c/DBN.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ void DBN__construct(DBN* this, int N, \
7474
}
7575

7676
void DBN__destruct(DBN* this) {
77-
77+
int i;
78+
for(i=0; i<this->n_layers; i++) {
79+
HiddenLayer__destruct(&(this->sigmoid_layers[i]));
80+
RBM__destruct(&(this->rbm_layers[i]));
81+
}
82+
free(this->sigmoid_layers);
83+
free(this->rbm_layers);
7884
}
7985

8086
void DBN_pretrain(DBN* this, int *input, double lr, int k, int epochs) {
@@ -561,13 +567,15 @@ void test_dbn(void) {
561567
}
562568
printf("\n");
563569
}
570+
571+
// destruct DBN
572+
DBN__destruct(&dbn);
564573

565574
}
566575

567576

568577

569578
int main(void) {
570579
test_dbn();
571-
572580
return 0;
573581
}

0 commit comments

Comments
 (0)