class_docstr: An unsupervised learning algorithm used to organize a corpus of documents into topics.
  
  The resulting topics contain word groupings based on their statistical distribution.
  Documents that contain frequent occurrences of words such as "bike", "car", "train",
  "mileage", and "speed" are likely to share a topic on "transportation" for example.
docstr: Neural Topic Model (NTM) is :class:`Estimator` used for unsupervised learning.
  
  This Estimator may be fit via calls to
  :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit`.
  It requires Amazon :class:`~sagemaker.amazon.record_pb2.Record` protobuf
  serialized data to be stored in S3. There is an utility
  :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.record_set`
  that can be used to upload data to S3 and creates
  :class:`~sagemaker.amazon.amazon_estimator.RecordSet` to be passed to
  the `fit` call.
  
  To learn more about the Amazon protobuf Record class and how to
  prepare bulk data in this format, please consult AWS technical
  documentation:
  https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html
  
  After this Estimator is fit, model data is stored in S3. The model
  may be deployed to an Amazon SageMaker Endpoint by invoking
  :meth:`~sagemaker.amazon.estimator.EstimatorBase.deploy`. As well as
  deploying an Endpoint, deploy returns a
  :class:`~sagemaker.amazon.ntm.NTMPredictor` object that can be used for
  inference calls using the trained model hosted in the SageMaker
  Endpoint.
  
  NTM Estimators can be configured by setting hyperparameters. The
  available hyperparameters for NTM are documented below.
  
  For further information on the AWS NTM algorithm, please consult AWS
  technical documentation:
  https://docs.aws.amazon.com/sagemaker/latest/dg/ntm.html
  
  Args:
      role (str): An AWS IAM role (either name or full ARN). The Amazon
          SageMaker training jobs and APIs that create Amazon SageMaker
          endpoints use this role to access training data and model
          artifacts. After the endpoint is created, the inference code
          might use the IAM role, if accessing AWS resource.
      instance_count: (int or PipelineVariable): Number of Amazon EC2 instances to use
          for training.
      instance_type (str or PipelineVariable): Type of EC2 instance to use for training,
          for example, 'ml.c4.xlarge'.
      num_topics (int): Required. The number of topics for NTM to find
          within the data.
      encoder_layers (list): Optional. Represents number of layers in the
          encoder and the output size of each layer.
      epochs (int): Optional. Maximum number of passes over the training
          data.
      encoder_layers_activation (str): Optional. Activation function to
          use in the encoder layers.
      optimizer (str): Optional. Optimizer to use for training.
      tolerance (float): Optional. Maximum relative change in the loss
          function within the last num_patience_epochs number of epochs
          below which early stopping is triggered.
      num_patience_epochs (int): Optional. Number of successive epochs
          over which early stopping criterion is evaluated.
      batch_norm (bool): Optional. Whether to use batch normalization
          during training.
      rescale_gradient (float): Optional. Rescale factor for gradient.
      clip_gradient (float): Optional. Maximum magnitude for each gradient
          component.
      weight_decay (float): Optional. Weight decay coefficient. Adds L2
          regularization.
      learning_rate (float): Optional. Learning rate for the optimizer.
      **kwargs: base class keyword argument values.
  
  .. tip::
  
      You can find additional parameters for initializing this class at
      :class:`~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase` and
      :class:`~sagemaker.estimator.EstimatorBase`.
docstr_tok: ["Neural","Topic","Model","(","NTM",")","is",":","class",":","`","Estimator","`","used","for","unsupervised","learning",".","This","Estimator","may","be","fit","via","calls","to",":","meth",":","`","~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit","`",".","It","requires","Amazon",":","class",":","`","~sagemaker.amazon.record_pb2.Record","`","protobuf","serialized","data","to","be","stored","in","S3",".","There","is","an","utility",":","meth",":","`","~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.record_set","`","that","can","be","used","to","upload","data","to","S3","and","creates",":","class",":","`","~sagemaker.amazon.amazon_estimator.RecordSet","`","to","be","passed","to","the","`","fit","`","call",".","To","learn","more","about","the","Amazon","protobuf","Record","class","and","how","to","prepare","bulk","data","in","this","format",",","please","consult","AWS","technical","documentation",":","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/cdf-training.html","After","this","Estimator","is","fit",",","model","data","is","stored","in","S3",".","The","model","may","be","deployed","to","an","Amazon","SageMaker","Endpoint","by","invoking",":","meth",":","`","~sagemaker.amazon.estimator.EstimatorBase.deploy","`",".","As","well","as","deploying","an","Endpoint",",","deploy","returns","a",":","class",":","`","~sagemaker.amazon.ntm.NTMPredictor","`","object","that","can","be","used","for","inference","calls","using","the","trained","model","hosted","in","the","SageMaker","Endpoint",".","NTM","Estimators","can","be","configured","by","setting","hyperparameters",".","The","available","hyperparameters","for","NTM","are","documented","below",".","For","further","information","on","the","AWS","NTM","algorithm",",","please","consult","AWS","technical","documentation",":","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/ntm.html","Args",":","role","(","str",")",":","An","AWS","IAM","role","(","either","name","or","full","ARN",")",".","The","Amazon","SageMaker","training","jobs","and","APIs","that","create","Amazon","SageMaker","endpoints","use","this","role","to","access","training","data","and","model","artifacts",".","After","the","endpoint","is","created",",","the","inference","code","might","use","the","IAM","role",",","if","accessing","AWS","resource",".","instance_count",":","(","int","or","PipelineVariable",")",":","Number","of","Amazon","EC2","instances","to","use","for","training",".","instance_type","(","str","or","PipelineVariable",")",":","Type","of","EC2","instance","to","use","for","training",",","for","example",",","'ml.c4.xlarge","'",".","num_topics","(","int",")",":","Required",".","The","number","of","topics","for","NTM","to","find","within","the","data",".","encoder_layers","(","list",")",":","Optional",".","Represents","number","of","layers","in","the","encoder","and","the","output","size","of","each","layer",".","epochs","(","int",")",":","Optional",".","Maximum","number","of","passes","over","the","training","data",".","encoder_layers_activation","(","str",")",":","Optional",".","Activation","function","to","use","in","the","encoder","layers",".","optimizer","(","str",")",":","Optional",".","Optimizer","to","use","for","training",".","tolerance","(","float",")",":","Optional",".","Maximum","relative","change","in","the","loss","function","within","the","last","num_patience_epochs","number","of","epochs","below","which","early","stopping","is","triggered",".","num_patience_epochs","(","int",")",":","Optional",".","Number","of","successive","epochs","over","which","early","stopping","criterion","is","evaluated",".","batch_norm","(","bool",")",":","Optional",".","Whether","to","use","batch","normalization","during","training",".","rescale_gradient","(","float",")",":","Optional",".","Rescale","factor","for","gradient",".","clip_gradient","(","float",")",":","Optional",".","Maximum","magnitude","for","each","gradient","component",".","weight_decay","(","float",")",":","Optional",".","Weight","decay","coefficient",".","Adds","L2","regularization",".","learning_rate","(","float",")",":","Optional",".","Learning","rate","for","the","optimizer",".","*","*","kwargs",":","base","class","keyword","argument","values",".","..","tip",":",":","You","can","find","additional","parameters","for","initializing","this","class","at",":","class",":","`","~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase","`","and",":","class",":","`","~sagemaker.estimator.EstimatorBase","`","."]
code: def __init__(
      self,
      role: Optional[Union[str, PipelineVariable]] = None,
      instance_count: Optional[Union[int, PipelineVariable]] = None,
      instance_type: Optional[Union[str, PipelineVariable]] = None,
      num_topics: Optional[int] = None,
      encoder_layers: Optional[List] = None,
      epochs: Optional[int] = None,
      encoder_layers_activation: Optional[str] = None,
      optimizer: Optional[str] = None,
      tolerance: Optional[float] = None,
      num_patience_epochs: Optional[int] = None,
      batch_norm: Optional[bool] = None,
      rescale_gradient: Optional[float] = None,
      clip_gradient: Optional[float] = None,
      weight_decay: Optional[float] = None,
      learning_rate: Optional[float] = None,
      **kwargs,
  ):
      """Neural Topic Model (NTM) is :class:`Estimator` used for unsupervised learning.
  
      This Estimator may be fit via calls to
      :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit`.
      It requires Amazon :class:`~sagemaker.amazon.record_pb2.Record` protobuf
      serialized data to be stored in S3. There is an utility
      :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.record_set`
      that can be used to upload data to S3 and creates
      :class:`~sagemaker.amazon.amazon_estimator.RecordSet` to be passed to
      the `fit` call.
  
      To learn more about the Amazon protobuf Record class and how to
      prepare bulk data in this format, please consult AWS technical
      documentation:
      https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html
  
      After this Estimator is fit, model data is stored in S3. The model
      may be deployed to an Amazon SageMaker Endpoint by invoking
      :meth:`~sagemaker.amazon.estimator.EstimatorBase.deploy`. As well as
      deploying an Endpoint, deploy returns a
      :class:`~sagemaker.amazon.ntm.NTMPredictor` object that can be used for
      inference calls using the trained model hosted in the SageMaker
      Endpoint.
  
      NTM Estimators can be configured by setting hyperparameters. The
      available hyperparameters for NTM are documented below.
  
      For further information on the AWS NTM algorithm, please consult AWS
      technical documentation:
      https://docs.aws.amazon.com/sagemaker/latest/dg/ntm.html
  
      Args:
          role (str): An AWS IAM role (either name or full ARN). The Amazon
              SageMaker training jobs and APIs that create Amazon SageMaker
              endpoints use this role to access training data and model
              artifacts. After the endpoint is created, the inference code
              might use the IAM role, if accessing AWS resource.
          instance_count: (int or PipelineVariable): Number of Amazon EC2 instances to use
              for training.
          instance_type (str or PipelineVariable): Type of EC2 instance to use for training,
              for example, 'ml.c4.xlarge'.
          num_topics (int): Required. The number of topics for NTM to find
              within the data.
          encoder_layers (list): Optional. Represents number of layers in the
              encoder and the output size of each layer.
          epochs (int): Optional. Maximum number of passes over the training
              data.
          encoder_layers_activation (str): Optional. Activation function to
              use in the encoder layers.
          optimizer (str): Optional. Optimizer to use for training.
          tolerance (float): Optional. Maximum relative change in the loss
              function within the last num_patience_epochs number of epochs
              below which early stopping is triggered.
          num_patience_epochs (int): Optional. Number of successive epochs
              over which early stopping criterion is evaluated.
          batch_norm (bool): Optional. Whether to use batch normalization
              during training.
          rescale_gradient (float): Optional. Rescale factor for gradient.
          clip_gradient (float): Optional. Maximum magnitude for each gradient
              component.
          weight_decay (float): Optional. Weight decay coefficient. Adds L2
              regularization.
          learning_rate (float): Optional. Learning rate for the optimizer.
          **kwargs: base class keyword argument values.
  
      .. tip::
  
          You can find additional parameters for initializing this class at
          :class:`~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase` and
          :class:`~sagemaker.estimator.EstimatorBase`.
      """
  
      super(NTM, self).__init__(
          role, instance_count, instance_type, **kwargs
      )
      self.num_topics = num_topics
      self.encoder_layers = encoder_layers
      self.epochs = epochs
      self.encoder_layers_activation = encoder_layers_activation
      self.optimizer = optimizer
      self.tolerance = tolerance
      self.num_patience_epochs = num_patience_epochs
      self.batch_norm = batch_norm
      self.rescale_gradient = rescale_gradient
      self.clip_gradient = clip_gradient
      self.weight_decay = weight_decay
      self.learning_rate = learning_rate
  
imports: from __future__ import absolute_import
  from typing import Optional, Union, List
  from sagemaker import image_uris
  from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase
  from sagemaker.amazon.common import RecordSerializer, RecordDeserializer
  from sagemaker.amazon.hyperparameter import Hyperparameter
  from sagemaker.amazon.validation import ge, le, isin
  from sagemaker.predictor import Predictor
  from sagemaker.model import Model
  from sagemaker.session import Session
  from sagemaker.utils import pop_out_unused_kwarg
  from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 1 to create a new NTM object from inherited base classes: AmazonAlgorithmEstimatorBase with example: obj = NTM(role, instance_count, instance_type, num_topics, encoder_layers, epochs, encoder_layers_activation, optimizer, tolerance, num_patience_epochs, batch_norm, rescale_gradient, clip_gradient, weight_decay, learning_rate)