From 54f83e153549dd1a63bcc8fa5e55fb171621a989 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Wed, 17 Jan 2018 18:05:07 +0000
Subject: [PATCH] Some fixes
---
src/softmax_layer.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/softmax_layer.c b/src/softmax_layer.c
index 31f3e03..5d15314 100644
--- a/src/softmax_layer.c
+++ b/src/softmax_layer.c
@@ -10,7 +10,7 @@
softmax_layer make_softmax_layer(int batch, int inputs, int groups)
{
assert(inputs%groups == 0);
- fprintf(stderr, "Softmax Layer: %d inputs\n", inputs);
+ fprintf(stderr, "softmax %4d\n", inputs);
softmax_layer l = {0};
l.type = SOFTMAX;
l.batch = batch;
@@ -32,21 +32,27 @@
return l;
}
+void softmax_tree(float *input, int batch, int inputs, float temp, tree *hierarchy, float *output)
+{
+ int b;
+ for(b = 0; b < batch; ++b){
+ int i;
+ int count = 0;
+ for(i = 0; i < hierarchy->groups; ++i){
+ int group_size = hierarchy->group_size[i];
+ softmax(input+b*inputs + count, group_size, temp, output+b*inputs + count);
+ count += group_size;
+ }
+ }
+}
+
void forward_softmax_layer(const softmax_layer l, network_state state)
{
int b;
int inputs = l.inputs / l.groups;
int batch = l.batch * l.groups;
if(l.softmax_tree){
- for(b = 0; b < batch; ++b){
- int i;
- int count = 0;
- for(i = 0; i < l.softmax_tree->groups; ++i){
- int group_size = l.softmax_tree->group_size[i];
- softmax(state.input+b*inputs + count, group_size, l.temperature, l.output+b*inputs + count);
- count += group_size;
- }
- }
+ softmax_tree(state.input, batch, inputs, l.temperature, l.softmax_tree, l.output);
} else {
for(b = 0; b < batch; ++b){
softmax(state.input+b*inputs, inputs, l.temperature, l.output+b*inputs);
--
Gitblit v1.10.0