public override void Dispose(bool disposing) { // Always free unmanaged objects, but conditionally free managed objets if this is being // called from Dispose() (as opposed a finalizer, currently not implemented) if (disposing) { if (log != null) { log.Dispose(); log = null; } } lock (this.vwLock) { if (vw != null) { vw.Dispose(); vw = null; } if (vwJson != null) { vwJson.Dispose(); vwJson = null; } vwDisposed = true; } base.Dispose(); }
public DecisionServiceLocal(string vwArgs, int modelUpdateInterval, TimeSpan expUnit) : base( new DecisionServiceConfiguration("") { OfflineMode = true, OfflineApplicationID = Guid.NewGuid().ToString(), DevelopmentMode = false }, new ApplicationClientMetadata { TrainArguments = vwArgs, InitialExplorationEpsilon = 1f }, new VWExplorer <TContext>(null, JsonTypeInspector.Default, false)) { this.log = new InMemoryLogger <TContext, int[]>(expUnit); this.Recorder = log; this.vw = new VowpalWabbit <TContext>( new VowpalWabbitSettings(vwArgs) { TypeInspector = JsonTypeInspector.Default, EnableStringExampleGeneration = this.config.DevelopmentMode, EnableStringFloatCompact = true } ); this.ModelUpdateInterval = modelUpdateInterval; }
public DecisionServiceLocal( string vwArgs, int modelUpdateInterval, TimeSpan expUnit) : base( new DecisionServiceConfiguration("") { OfflineMode = true, OfflineApplicationID = Guid.NewGuid().ToString(), DevelopmentMode = false }, new ApplicationClientMetadata { TrainArguments = vwArgs, InitialExplorationEpsilon = 1f }, // String (json) contexts require a different type of internal policy ((typeof(TContext) == typeof(string)) ? new VWJsonExplorer(null, false) as IContextMapper <TContext, ActionProbability[]> : new VWExplorer <TContext>(null, JsonTypeInspector.Default, false))) { this.log = new InMemoryLogger <TContext, int[]>(expUnit); this.Recorder = log; // String (json) contexts are handled via a non-generic VW instance, whereas all other // context types use a generic VW instance if (typeof(TContext) == typeof(string)) { this.vwJson = new VowpalWabbit( new VowpalWabbitSettings(vwArgs) { TypeInspector = JsonTypeInspector.Default, EnableStringExampleGeneration = this.config.DevelopmentMode, EnableStringFloatCompact = true } ); } else { this.vw = new VowpalWabbit <TContext>( new VowpalWabbitSettings(vwArgs) { TypeInspector = JsonTypeInspector.Default, EnableStringExampleGeneration = this.config.DevelopmentMode, EnableStringFloatCompact = true } ); } this.ModelUpdateInterval = modelUpdateInterval; }