File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,8 @@ static bool compute_vector_statistics(std::vector<tensor_statistics> & tstats, c
206206 if (e.activations .empty ()) {
207207 if (sum > 0 ) {
208208 for (const auto act : activations) {
209- if (const float p = act / sum; p > 0 ) {
210- entropy -= p * std::log2 (p);
211- }
209+ const float p = act / sum;
210+ if (p > 0 ) { entropy -= p * std::log2 (p); }
212211 }
213212 }
214213 } else {
@@ -231,21 +230,22 @@ static bool compute_vector_statistics(std::vector<tensor_statistics> & tstats, c
231230 int zd_score = 0 ;
232231 if (std_deviation > 0 .0f ) {
233232 for (const auto act : activations) {
234- if (const float z = (act - mean) / std_deviation; std::fabs (z) > 1 .0f ) zd_score++;
233+ const float z = (act - mean) / std_deviation;
234+ if (std::fabs (z) > 1 .0f ) { zd_score++; }
235235 }
236236 }
237237
238238 auto & ts = tstats.emplace_back ();
239- ts.tensor = name;
240- ts.stats = e;
241- ts.sum_values = sum;
242- ts.mean_values = mean;
243- ts.max_values = max;
244- ts.min_values = min;
245- ts.elements = static_cast <int >(activations.size ());
246- ts.std_deviation = std_deviation;
247- ts.entropy = entropy;
248- ts.zd_score = static_cast <float >(zd_score) / ts.elements ;
239+ ts.tensor = name;
240+ ts.stats = e;
241+ ts.sum_values = sum;
242+ ts.mean_values = mean;
243+ ts.max_values = max;
244+ ts.min_values = min;
245+ ts.elements = static_cast <int >(activations.size ());
246+ ts.std_deviation = std_deviation;
247+ ts.entropy = entropy;
248+ ts.zd_score = static_cast <float >(zd_score) / ts.elements ;
249249
250250 return e.activations .empty ();
251251}
You can’t perform that action at this time.
0 commit comments