@@ -21,6 +21,7 @@ limitations under the License.
21
21
using System . Diagnostics ;
22
22
using System . IO ;
23
23
using System . Linq ;
24
+ using System . Threading . Tasks ;
24
25
using Tensorflow ;
25
26
using TensorFlowNET . Examples . Utility ;
26
27
using static Tensorflow . Binding ;
@@ -381,10 +382,15 @@ private void cache_bottlenecks(Session sess, Dictionary<string, Dictionary<strin
381
382
Tensor resized_input_tensor , Tensor bottleneck_tensor , string module_name )
382
383
{
383
384
int how_many_bottlenecks = 0 ;
384
- foreach ( var ( label_name , label_lists ) in image_lists )
385
+ var kvs = image_lists . ToArray ( ) ;
386
+ var categories = new string [ ] { "training" , "testing" , "validation" } ;
387
+ Parallel . For ( 0 , kvs . Length , i =>
385
388
{
386
- foreach ( var category in new string [ ] { "training" , "testing" , "validation" } )
389
+ var ( label_name , label_lists ) = kvs [ i ] ;
390
+
391
+ Parallel . For ( 0 , categories . Length , j =>
387
392
{
393
+ var category = categories [ j ] ;
388
394
var category_list = label_lists [ category ] ;
389
395
foreach ( var ( index , unused_base_name ) in enumerate ( category_list ) )
390
396
{
@@ -395,8 +401,8 @@ private void cache_bottlenecks(Session sess, Dictionary<string, Dictionary<strin
395
401
if ( how_many_bottlenecks % 300 == 0 )
396
402
print ( $ "{ how_many_bottlenecks } bottleneck files created.") ;
397
403
}
398
- }
399
- }
404
+ } ) ;
405
+ } ) ;
400
406
}
401
407
402
408
private float [ ] get_or_create_bottleneck ( Session sess , Dictionary < string , Dictionary < string , string [ ] > > image_lists ,
0 commit comments