@@ -64,8 +64,10 @@ def Face2StepModel(pointsN, eyeSize, latentSize, embeddingsSize):
64
64
for i , EFeat in enumerate (encodedEFList ):
65
65
combined = CFusingBlock (name = 'F2S/ResMul-%d' % i )([
66
66
combined ,
67
- sMLP (sizes = [latentSize ] * 1 , activation = 'relu' , name = 'F2S/MLP-%d' % i )(
68
- L .Concatenate (- 1 )([combined , encodedP , EFeat , embeddings ])
67
+ sMLP (sizes = [latentSize ] * 3 , activation = 'relu' , name = 'F2S/MLP-%d' % i )(
68
+ L .LayerNormalization ()(
69
+ L .Concatenate (- 1 )([combined , encodedP , EFeat , embeddings ])
70
+ )
69
71
)
70
72
])
71
73
# save intermediate output
@@ -74,6 +76,7 @@ def Face2StepModel(pointsN, eyeSize, latentSize, embeddingsSize):
74
76
continue
75
77
76
78
combined = L .Dense (latentSize , name = 'F2S/Combine' )(combined )
79
+ combined = L .LayerNormalization ()(combined )
77
80
# combined = CQuantizeLayer()(combined)
78
81
return tf .keras .Model (
79
82
inputs = {
@@ -92,7 +95,7 @@ def Step2LatentModel(latentSize, embeddingsSize):
92
95
latents = L .Input ((None , latentSize ))
93
96
embeddingsInput = L .Input ((None , embeddingsSize ))
94
97
T = L .Input ((None , 1 ))
95
- embeddings = embeddingsInput [..., : 1 ] * 0.0
98
+ embeddings = embeddingsInput
96
99
97
100
stepsData = latents
98
101
intermediate = {}
@@ -105,11 +108,11 @@ def Step2LatentModel(latentSize, embeddingsSize):
105
108
intermediate ['S2L/enc0' ] = temporal
106
109
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
107
110
for blockId in range (3 ):
108
- temp = L .Concatenate (- 1 )([temporal , encodedT ])
109
- for _ in range (1 ):
111
+ temp = L .Concatenate (- 1 )([temporal , encodedT , embeddings ])
112
+ for _ in range (3 ):
110
113
temp = L .LSTM (latentSize , return_sequences = True )(temp )
111
- temp = sMLP (sizes = [latentSize ] * 1 , activation = 'relu' )(
112
- L .Concatenate (- 1 )([temporal , temp ])
114
+ temp = sMLP (sizes = [latentSize ] * 3 , activation = 'relu' )(
115
+ L .Concatenate (- 1 )([temporal , temp , encodedT , embeddings ])
113
116
)
114
117
temporal = CFusingBlock ()([temporal , temp ])
115
118
intermediate ['S2L/ResLSTM-%d' % blockId ] = temporal
@@ -165,6 +168,7 @@ def Face2LatentModel(
165
168
# add diffusion features to the embeddings
166
169
emb = L .Concatenate (- 1 )([emb , encodedDT , encodedDP ])
167
170
171
+ emb = L .LayerNormalization ()(emb )
168
172
Face2Step = Face2StepModel (pointsN , eyeSize , latentSize , embeddingsSize = emb .shape [- 1 ])
169
173
Step2Latent = Step2LatentModel (latentSize , embeddingsSize = emb .shape [- 1 ])
170
174
@@ -196,7 +200,9 @@ def Face2LatentModel(
196
200
}
197
201
res ['result' ] = IntermediatePredictor (
198
202
shift = 0.0 if diffusion else 0.5 # shift points to the center, if not using diffusion
199
- )(res ['latent' ])
203
+ )(
204
+ L .Concatenate (- 1 )([res ['latent' ], T , emb ])
205
+ )
200
206
201
207
if diffusion :
202
208
inputs ['diffusionT' ] = diffusionT
0 commit comments