2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System ;
5
6
using System . Linq ;
6
7
using Microsoft . ML . Internal . Utilities ;
7
8
using Microsoft . ML . Runtime ;
@@ -99,7 +100,7 @@ public EstimatorChain<TNewTrans> Append<TNewTrans>(IEstimator<TNewTrans> estimat
99
100
/// cached data. It is helpful to have a caching checkpoint before trainers or feature engineering that take multiple data passes.
100
101
/// It is also helpful to have after a slow operation, for example after dataset loading from a slow source or after feature
101
102
/// engineering that is slow on its apply phase, if downstream estimators will do multiple passes over the output of this operation.
102
- /// Adding a cache checkpoint at the end of an <see cref="EstimatorChain{TLastTransformer}"/> is meaningless and should be avoided.
103
+ /// Adding a cache checkpoint at the begin or end of an <see cref="EstimatorChain{TLastTransformer}"/> is meaningless and should be avoided.
103
104
/// Cache checkpoints should be removed if disk thrashing or OutOfMemory exceptions are seen, which can occur on when the featured
104
105
/// dataset immediately prior to the checkpoint is larger than available RAM.
105
106
/// </summary>
@@ -108,9 +109,12 @@ public EstimatorChain<TLastTransformer> AppendCacheCheckpoint(IHostEnvironment e
108
109
{
109
110
Contracts . CheckValue ( env , nameof ( env ) ) ;
110
111
111
- if ( _estimators . Length == 0 || _needCacheAfter . Last ( ) )
112
+ if ( _estimators . Length == 0 )
113
+ throw new InvalidOperationException ( "Current estimator chain has no estimator, can't append cache checkpoint." ) ;
114
+
115
+ if ( _needCacheAfter . Last ( ) )
112
116
{
113
- // If there are no estimators, or if we already need to cache after this, we don't need to do anything else.
117
+ // If we already need to cache after this, we don't need to do anything else.
114
118
return this ;
115
119
}
116
120
0 commit comments