class_docstr: Manages a PyTorch model for training.
class_docstr_tok: ["Manages","a","PyTorch","model","for","training","."]
docstr: Evaluates the model on the validation data set.
docstr_tok: ["Evaluates","the","model","on","the","validation","data","set","."]
code: def validate(
      self,
      data_creator,
      batch_size=32,
      num_steps=None,
      profile=False,
      wrap_dataloader=None,
      callbacks=None,
  ):
      """Evaluates the model on the validation data set."""
      if not self.models:
          invalidInputError(
              False, "You must provide a model for train and evaluate."
          )
  
      config = copy.copy(self.config)
      self._toggle_profiling(profile=profile)
  
      if OrcaContext.serialize_data_creator:
          with FileLock(
              os.path.join(tempfile.gettempdir(), ".orcadata.lock")
          ):
              loader = data_creator(config, batch_size)
      else:
          loader = data_creator(config, batch_size)
  
      if wrap_dataloader is None:
          if TorchRunner.should_wrap_dataloader(loader):
              loader = self.with_sampler(loader)
      elif wrap_dataloader is True:
          loader = self.with_sampler(loader)
      self.val_loader = loader
      loader = iter(loader)
  
      with self.timers.record("validation"):
          self.num_steps = num_steps
          validation_stats = self._validate(
              loader,
              metrics=self.metrics,
              num_steps=num_steps,
              callbacks=callbacks,
          )
          del self.num_steps
      if profile:
          validation_stats.update(profile=self.timers.stats())
      return validation_stats
  
imports: from filelock import FileLock
  import logging
  import os
  import copy
  import tempfile
  import math
  import torch
  import torch.nn
  import numpy
  from torch.utils.data import DataLoader, IterableDataset
  from bigdl.orca.learn.metrics import Metric
  from bigdl.orca import OrcaContext
  from bigdl.orca.learn.pytorch import utils
  from bigdl.orca.learn.pytorch.utils import AverageMeterCollection, NUM_SAMPLES, get_batchsize, index_concatenate, split_predict_cols
  from bigdl.orca.learn.pytorch.core import BaseRunner
  from bigdl.dllib.utils.log4Error import invalidInputError
label_desc: Use image node_id 12 for calling the TorchRunner obj's underlying member method code with example usage: obj.validate(data_creator, batch_size, num_steps, profile, wrap_dataloader, callbacks) and returns: validation_stats