From 2eb13d63b15a8ac908d6fa324c7f3d19141ca570 Mon Sep 17 00:00:00 2001
From: natanielruiz <nataniel777@hotmail.com>
Date: 星期六, 12 八月 2017 08:57:15 +0800
Subject: [PATCH] Temperature softmax and 10 shape PCA regression.

---
 code/hopenet.py |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/code/hopenet.py b/code/hopenet.py
index 9ba8f04..1b94fa1 100644
--- a/code/hopenet.py
+++ b/code/hopenet.py
@@ -106,7 +106,7 @@
     # This is just Hopenet with 3 output layers for yaw, pitch and roll.
     def __init__(self, block, layers, num_bins, shape_bins):
         self.inplanes = 64
-        super(Hopenet, self).__init__()
+        super(Hopenet_shape, self).__init__()
         self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
                                bias=False)
         self.bn1 = nn.BatchNorm2d(64)
@@ -120,7 +120,16 @@
         self.fc_yaw = nn.Linear(512 * block.expansion, num_bins)
         self.fc_pitch = nn.Linear(512 * block.expansion, num_bins)
         self.fc_roll = nn.Linear(512 * block.expansion, num_bins)
+        self.fc_shape_0 = nn.Linear(512 * block.expansion, shape_bins)
         self.fc_shape_1 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_2 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_3 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_4 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_5 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_6 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_7 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_8 = nn.Linear(512 * block.expansion, shape_bins)
+        self.fc_shape_9 = nn.Linear(512 * block.expansion, shape_bins)
 
         for m in self.modules():
             if isinstance(m, nn.Conv2d):
@@ -163,6 +172,17 @@
         yaw = self.fc_yaw(x)
         pitch = self.fc_pitch(x)
         roll = self.fc_roll(x)
-        shape_1 = self.fc_shape_1(x)
 
-        return yaw, pitch, roll, shape_1
+        shape = []
+        shape.append(self.fc_shape_0(x))
+        shape.append(self.fc_shape_1(x))
+        shape.append(self.fc_shape_2(x))
+        shape.append(self.fc_shape_3(x))
+        shape.append(self.fc_shape_4(x))
+        shape.append(self.fc_shape_5(x))
+        shape.append(self.fc_shape_6(x))
+        shape.append(self.fc_shape_7(x))
+        shape.append(self.fc_shape_8(x))
+        shape.append(self.fc_shape_9(x))
+
+        return yaw, pitch, roll, shape

--
Gitblit v1.8.0