Source code for pytorch_lightning.callbacks.model_summary
# Copyright The PyTorch Lightning team.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License."""Model Summary=============Generates a summary of all layers in a :class:`~pytorch_lightning.core.module.LightningModule`.The string representation of this summary prints a table with columns containingthe name, type and number of parameters for each layer."""importloggingfromtypingimportList,Tuple,Unionimportpytorch_lightningasplfrompytorch_lightning.callbacks.callbackimportCallbackfrompytorch_lightning.utilities.model_summaryimportDeepSpeedSummaryfrompytorch_lightning.utilities.model_summaryimportModelSummaryasSummaryfrompytorch_lightning.utilities.model_summaryimportsummarizefrompytorch_lightning.utilities.model_summary.model_summaryimport_format_summary_tablelog=logging.getLogger(__name__)
[docs]classModelSummary(Callback):r""" Generates a summary of all layers in a :class:`~pytorch_lightning.core.module.LightningModule`. Args: max_depth: The maximum depth of layer nesting that the summary will include. A value of 0 turns the layer summary off. Example:: >>> from pytorch_lightning import Trainer >>> from pytorch_lightning.callbacks import ModelSummary >>> trainer = Trainer(callbacks=[ModelSummary(max_depth=1)]) """def__init__(self,max_depth:int=1)->None:self._max_depth:int=max_depth
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. Read PyTorch Lightning's Privacy Policy.