current position:Home>Two important self-learning functions in pytorch dir(); help()

Two important self-learning functions in pytorch dir(); help()

2022-08-06 08:52:54chuanauc

ref : P3. Python学习中的两大法宝函数(当然也可以用在PyTorch)_哔哩哔哩_bilibili

1.dir() :

We're going to learn a function in a library,First we have to open the library,to find the function to understand,怎么打开呢,就是用dir()函数.

2.help()函数:

When we finally locate a function,就可以使用help()function to check the official documentation.

注意:Add a function calledaaa() ,那么使用help查看的时候,一定是help(aaa).即,记得把aaa()的()去掉

我们以 学习 torch.cuda.is_available()  这个函数为例:

首先:

于是,We want to know this torch.cuda.is_available() What exactly does the function do,方法就是先用dir()Functions go deep into the corresponding function position layer by layer,然后调用help()The function is officially explained:

1.我们输入dir(torch)  进入torch So it shows a lot(Not all displayed yet)的torch库中的函数,或者torchlibrary within library(torchSublibraries included in the library)

In [4]: dir(torch)
Out[4]: 
['AVG',
 'AggregationType',
 'AliasDb',
 'AnyType',
 'Argument',
 'ArgumentSpec',
 'BFloat16Storage',
 'BFloat16Tensor',
 'BenchmarkConfig',
 'BenchmarkExecutionStats',
 'Block',
 'BoolStorage',
 'BoolTensor',
 'BoolType',
 'BufferDict',
 'ByteStorage',
 'ByteTensor',
 'CONV_BN_FUSION',
 'CallStack',
 'Capsule',
 'CharStorage',
 'CharTensor',
 'ClassType',
 'Code',
 'CompilationUnit',
 'CompleteArgumentSpec',
 'ComplexDoubleStorage',
 'ComplexFloatStorage',
 'ComplexType',
 'ConcreteModuleType',
 'ConcreteModuleTypeBuilder',
 'CudaBFloat16StorageBase',
 'CudaBoolStorageBase',
 'CudaByteStorageBase',
 'CudaCharStorageBase',
 'CudaComplexDoubleStorageBase',
 'CudaComplexFloatStorageBase',
 'CudaDoubleStorageBase',
 'CudaFloatStorageBase',
 'CudaHalfStorageBase',
 'CudaIntStorageBase',
 'CudaLongStorageBase',
 'CudaShortStorageBase',
 'DeepCopyMemoTable',
 'DeserializationStorageContext',
 'DeviceObjType',
 'DictType',
 'DisableTorchFunction',
 'DoubleStorage',
 'DoubleTensor',
 'EnumType',
 'ErrorReport',
 'ExecutionPlan',
 'FUSE_ADD_RELU',
 'FatalError',
 'FileCheck',
 'FloatStorage',
 'FloatTensor',
 'FloatType',
 'FunctionSchema',
 'Future',
 'FutureType',
 'Generator',
 'Gradient',
 'Graph',
 'GraphExecutorState',
 'HOIST_CONV_PACKED_PARAMS',
 'HalfStorage',
 'HalfStorageBase',
 'HalfTensor',
 'INSERT_FOLD_PREPACK_OPS',
 'IODescriptor',
 'InferredType',
 'IntStorage',
 'IntTensor',
 'IntType',
 'InterfaceType',
 'JITException',
 'ListType',
 'LiteScriptModule',
 'LockingLogger',
 'LoggerBase',
 'LongStorage',
 'LongTensor',
 'MobileOptimizerType',
 'ModuleDict',
 'Node',
 'NoneType',
 'NoopLogger',
 'NumberType',
 'OperatorInfo',
 'OptionalType',
 'PRIVATE_OPS',
 'ParameterDict',
 'PyObjectType',
 'PyTorchFileReader',
 'PyTorchFileWriter',
 'QInt32Storage',
 'QInt32StorageBase',
 'QInt8Storage',
 'QInt8StorageBase',
 'QUInt4x2Storage',
 'QUInt8Storage',
 'REMOVE_DROPOUT',
 'RRefType',
 'SUM',
 'ScriptClass',
 'ScriptClassFunction',
 'ScriptDict',
 'ScriptDictIterator',
 'ScriptDictKeyIterator',
 'ScriptFunction',
 'ScriptList',
 'ScriptListIterator',
 'ScriptMethod',
 'ScriptModule',
 'ScriptModuleSerializer',
 'ScriptObject',
 'ScriptObjectProperty',
 'SerializationStorageContext',
 'Set',
 'ShortStorage',
 'ShortTensor',
 'Size',
 'StaticModule',
 'Storage',
 'Stream',
 'StreamObjType',
 'StringType',
 'TYPE_CHECKING',
 'Tensor',
 'TensorType',
 'ThroughputBenchmark',
 'TracingState',
 'TupleType',
 'Type',
 'USE_GLOBAL_DEPS',
 'USE_RTLD_GLOBAL_WITH_LIBTORCH',
 'UnionType',
 'Use',
 'Value',
 '_C',
 '_StorageBase',
 '_VF',
 '__all__',
 '__annotations__',
 '__builtins__',
 '__cached__',
 '__config__',
 '__doc__',
 '__file__',
 '__future__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 '_adaptive_avg_pool2d',
 '_adaptive_avg_pool3d',
 '_add_batch_dim',
 '_add_relu',
 '_add_relu_',
 '_aminmax',
 '_amp_foreach_non_finite_check_and_unscale_',
 '_amp_update_scale_',
 '_assert',
 '_assert_async',
 '_baddbmm_mkl_',
 '_batch_norm_impl_index',
 '_cast_Byte',
 '_cast_Char',
 '_cast_Double',
 '_cast_Float',
 '_cast_Half',
 '_cast_Int',
 '_cast_Long',
 '_cast_Short',
 '_cat',
 '_choose_qparams_per_tensor',
 '_classes',
 '_coalesce',
 '_compute_linear_combination',
 '_conj',
 '_conj_physical',
 '_convert_indices_from_coo_to_csr',
 '_convolution',
 '_convolution_mode',
 '_convolution_nogroup',
 '_copy_from',
 '_copy_from_and_resize',
 '_ctc_loss',
 '_cudnn_ctc_loss',
 '_cudnn_init_dropout_state',
 '_cudnn_rnn',
 '_cudnn_rnn_flatten_weight',
 '_cufft_clear_plan_cache',
 '_cufft_get_plan_cache_max_size',
 '_cufft_get_plan_cache_size',
 '_cufft_set_plan_cache_max_size',
 '_cummax_helper',
 '_cummin_helper',
 '_debug_has_internal_overlap',
 '_det_lu_based_helper',
 '_det_lu_based_helper_backward_helper',
 '_dim_arange',
 '_dirichlet_grad',
 '_embedding_bag',
 '_embedding_bag_forward_only',
 '_empty_affine_quantized',
 '_empty_per_channel_affine_quantized',
 '_euclidean_dist',
 '_fake_quantize_learnable_per_channel_affine',
 '_fake_quantize_learnable_per_tensor_affine',
 '_fake_quantize_per_tensor_affine_cachemask_tensor_qparams',
 '_fft_c2c',
 '_fft_c2r',
 '_fft_r2c',
 '_foreach_abs',
 '_foreach_abs_',
 '_foreach_acos',
 '_foreach_acos_',
 '_foreach_add',
 '_foreach_add_',
 '_foreach_addcdiv',
 '_foreach_addcdiv_',
 '_foreach_addcmul',
 '_foreach_addcmul_',
 '_foreach_asin',
 '_foreach_asin_',
 '_foreach_atan',
 '_foreach_atan_',
 '_foreach_ceil',
 '_foreach_ceil_',
 '_foreach_cos',
 '_foreach_cos_',
 '_foreach_cosh',
 '_foreach_cosh_',
 '_foreach_div',
 '_foreach_div_',
 '_foreach_erf',
 '_foreach_erf_',
 '_foreach_erfc',
 '_foreach_erfc_',
 '_foreach_exp',
 '_foreach_exp_',
 '_foreach_expm1',
 '_foreach_expm1_',
 '_foreach_floor',
 '_foreach_floor_',
 '_foreach_frac',
 '_foreach_frac_',
 '_foreach_lgamma',
 '_foreach_lgamma_',
 '_foreach_log',
 '_foreach_log10',
 '_foreach_log10_',
 '_foreach_log1p',
 '_foreach_log1p_',
 '_foreach_log2',
 '_foreach_log2_',
 '_foreach_log_',
 '_foreach_maximum',
 '_foreach_minimum',
 '_foreach_mul',
 '_foreach_mul_',
 '_foreach_neg',
 '_foreach_neg_',
 '_foreach_reciprocal',
 '_foreach_reciprocal_',
 '_foreach_round',
 '_foreach_round_',
 '_foreach_sigmoid',
 '_foreach_sigmoid_',
 '_foreach_sin',
 '_foreach_sin_',
 '_foreach_sinh',
 '_foreach_sinh_',
 '_foreach_sqrt',
 '_foreach_sqrt_',
 '_foreach_sub',
 '_foreach_sub_',
 '_foreach_tan',
 '_foreach_tan_',
 '_foreach_tanh',
 '_foreach_tanh_',
 '_foreach_trunc',
 '_foreach_trunc_',
 '_foreach_zero_',
 '_fused_dropout',
 '_fused_moving_avg_obs_fq_helper',
 '_grid_sampler_2d_cpu_fallback',
 '_has_compatible_shallow_copy_type',
 '_import_dotted_name',
 '_index_copy_',
 '_index_put_impl_',
 '_initExtension',
 '_jit_internal',
 '_linalg_inv_out_helper_',
 '_linalg_qr_helper',
 '_linalg_utils',
 '_load_global_deps',
 '_lobpcg',
 '_log_softmax',
 '_log_softmax_backward_data',
 '_logcumsumexp',
 '_lowrank',
 '_lu_with_info',
 '_make_dual',
 '_make_per_channel_quantized_tensor',
 '_make_per_tensor_quantized_tensor',
 '_masked_scale',
 '_mkldnn',
 '_mkldnn_reshape',
 '_mkldnn_transpose',
 '_mkldnn_transpose_',
 '_namedtensor_internals',
 '_neg_view',
 '_nnpack_available',
 '_nnpack_spatial_convolution',
 '_ops',
 '_pack_padded_sequence',
 '_pad_packed_sequence',
 '_pin_memory',
 '_register_device_module',
 '_remove_batch_dim',
 '_reshape_from_tensor',
 '_rowwise_prune',
 '_s_where',
 '_sample_dirichlet',
 '_saturate_weight_to_fp16',
 '_shape_as_tensor',
 '_six',
 '_sobol_engine_draw',
 '_sobol_engine_ff_',
 '_sobol_engine_initialize_state_',
 '_sobol_engine_scramble_',
 '_softmax',
 '_softmax_backward_data',
 '_sources',
 '_sparse_addmm',
 '_sparse_coo_tensor_unsafe',
 '_sparse_csr_tensor_unsafe',
 '_sparse_log_softmax',
 '_sparse_log_softmax_backward_data',
 '_sparse_mask_helper',
 '_sparse_mm',
 '_sparse_softmax',
 '_sparse_softmax_backward_data',
 '_sparse_sparse_matmul',
 '_sparse_sum',
 '_stack',
 '_standard_gamma',
 '_standard_gamma_grad',
 '_storage_classes',
 '_string_classes',
 '_tensor',
 '_tensor_classes',
 '_tensor_str',
 '_test_serialization_subcmul',
 '_to_cpu',
 '_trilinear',
 '_unique',
 '_unique2',
 '_unpack_dual',
 '_use_cudnn_ctc_loss',
 '_use_cudnn_rnn_flatten_weight',
 '_utils',
 '_utils_internal',
 '_validate_sparse_coo_tensor_args',
 '_validate_sparse_csr_tensor_args',
 '_vmap_internals',
 '_weight_norm',
 '_weight_norm_cuda_interface',
 'abs',
 'abs_',
 'absolute',
 'acos',
 'acos_',
 'acosh',
 'acosh_',
 'adaptive_avg_pool1d',
 'adaptive_max_pool1d',
 'add',
 'addbmm',
 'addcdiv',
 'addcmul',
 'addmm',
 'addmv',
 'addmv_',
 'addr',
 'affine_grid_generator',
 'align_tensors',
 'all',
 'allclose',
 'alpha_dropout',
 'alpha_dropout_',
 'amax',
 'amin',
 'aminmax',
 'angle',
 'any',
 'ao',
 'arange',
 'arccos',
 'arccos_',
 'arccosh',
 'arccosh_',
 'arcsin',
 'arcsin_',
 'arcsinh',
 'arcsinh_',
 'arctan',
 'arctan_',
 'arctanh',
 'arctanh_',
 'are_deterministic_algorithms_enabled',
 'argmax',
 'argmin',
 'argsort',
 'as_strided',
 'as_strided_',
 'as_tensor',
 'asin',
 'asin_',
 'asinh',
 'asinh_',
 'atan',
 'atan2',
 'atan_',
 'atanh',
 'atanh_',
 'atleast_1d',
 'atleast_2d',
 'atleast_3d',
 'attr',
 'autocast',
 'autocast_decrement_nesting',
 'autocast_increment_nesting',
 'autocast_mode',
 'autograd',
 'avg_pool1d',
 'backends',
 'baddbmm',
 'bartlett_window',
 'batch_norm',
 'batch_norm_backward_elemt',
 'batch_norm_backward_reduce',
 'batch_norm_elemt',
 'batch_norm_gather_stats',
 'batch_norm_gather_stats_with_counts',
 'batch_norm_stats',
 'batch_norm_update_stats',
 'bernoulli',
 'bfloat16',
 'bilinear',
 'binary_cross_entropy_with_logits',
 'bincount',
 'binomial',
 'bitwise_and',
 'bitwise_left_shift',
 'bitwise_not',
 'bitwise_or',
 'bitwise_right_shift',
 'bitwise_xor',
 'blackman_window',
 'block_diag',
 'bmm',
 'bool',
 'broadcast_shapes',
 'broadcast_tensors',
 'broadcast_to',
 'bucketize',
 'can_cast',
 'candidate',
 'cartesian_prod',
 'cat',
 'cdist',
 'cdouble',
 'ceil',
 'ceil_',
 'celu',
 'celu_',
 'cfloat',
 'chain_matmul',
 'channel_shuffle',
 'channels_last',
 'channels_last_3d',
 'cholesky',
 'cholesky_inverse',
 'cholesky_solve',
 'choose_qparams_optimized',
 'chunk',
 'clamp',
 'clamp_',
 'clamp_max',
 'clamp_max_',
 'clamp_min',
 'clamp_min_',
 'classes',
 'clear_autocast_cache',
 'clip',
 'clip_',
 'clone',
 'column_stack',
 'combinations',
 'compiled_with_cxx11_abi',
 'complex',
 'complex128',
 'complex32',
 'complex64',
 'concat',
 'conj',
 'conj_physical',
 'conj_physical_',
 'constant_pad_nd',
 'contiguous_format',
 'conv1d',
 'conv2d',
 'conv3d',
 'conv_tbc',
 'conv_transpose1d',
 'conv_transpose2d',
 'conv_transpose3d',
 'convolution',
 'copysign',
 'corrcoef',
 'cos',
 'cos_',
 'cosh',
 'cosh_',
 'cosine_embedding_loss',
 'cosine_similarity',
 'count_nonzero',
 'cov',
 'cpp',
 'cpu',
 'cross',
 'ctc_loss',
 'ctypes',
 'cuda',
 'cudnn_affine_grid_generator',
 'cudnn_batch_norm',
 'cudnn_convolution',
 'cudnn_convolution_add_relu',
 'cudnn_convolution_relu',
 'cudnn_convolution_transpose',
 'cudnn_grid_sampler',
 'cudnn_is_acceptable',
 'cummax',
 'cummin',
 'cumprod',
 'cumsum',
 'cumulative_trapezoid',
 'default_generator',
 'deg2rad',
 'deg2rad_',
 'dequantize',
 'det',
 'detach',
 'detach_',
 'device',
 'diag',
 'diag_embed',
 'diagflat',
 'diagonal',
 'diff',
 'digamma',
 'dist',
 'distributed',
 'distributions',
 'div',
 'divide',
 'dot',
 'double',
 'dropout',
 'dropout_',
 'dsmm',
 'dsplit',
 'dstack',
 'dtype',
 'e',
 'eig',
 'einsum',
 'embedding',
 'embedding_bag',
 'embedding_renorm_',
 'empty',
 'empty_like',
 'empty_quantized',
 'empty_strided',
 'enable_grad',
 'eq',
 'equal',
 'erf',
 'erf_',
 'erfc',
 'erfc_',
 'erfinv',
 'exp',
 'exp2',
 'exp2_',
 'exp_',
 'expm1',
 'expm1_',
 'eye',
 'fake_quantize_per_channel_affine',
 'fake_quantize_per_tensor_affine',
 'fbgemm_linear_fp16_weight',
 'fbgemm_linear_fp16_weight_fp32_activation',
 'fbgemm_linear_int8_weight',
 'fbgemm_linear_int8_weight_fp32_activation',
 'fbgemm_linear_quantize_weight',
 'fbgemm_pack_gemm_matrix_fp16',
 'fbgemm_pack_quantized_matrix',
 'feature_alpha_dropout',
 'feature_alpha_dropout_',
 'feature_dropout',
 'feature_dropout_',
 'fft',
 'fill_',
 'finfo',
 'fix',
 'fix_',
 'flatten',
 'flip',
 'fliplr',
 'flipud',
 'float',
 'float16',
 'float32',
 'float64',
 'float_power',
 'floor',
 'floor_',
 'floor_divide',
 'fmax',
 'fmin',
 'fmod',
 'fork',
 'frac',
 'frac_',
 'frexp',
 'frobenius_norm',
 'from_dlpack',
 'from_file',
 'from_numpy',
 'frombuffer',
 'full',
 'full_like',
 'functional',
 'fused_moving_avg_obs_fake_quant',
 'futures',
 'gather',
 'gcd',
 'gcd_',
 'ge',
 'geqrf',
 'ger',
 'get_autocast_cpu_dtype',
 'get_autocast_gpu_dtype',
 'get_default_dtype',
 'get_device',
 'get_file_path',
 'get_num_interop_threads',
 'get_num_threads',
 'get_rng_state',
 'gradient',
 'greater',
 'greater_equal',
 'grid_sampler',
 'grid_sampler_2d',
 'grid_sampler_3d',
 'group_norm',
 'gru',
 'gru_cell',
 'gt',
 'half',
 'hamming_window',
 'hann_window',
 'hardshrink',
 'has_cuda',
 'has_cudnn',
 'has_lapack',
 'has_mkl',
 'has_mkldnn',
 'has_mlc',
 'has_openmp',
 'has_spectral',
 'heaviside',
 'hinge_embedding_loss',
 'histc',
 'histogram',
 'hsmm',
 'hsplit',
 'hspmm',
 'hstack',
 'hub',
 'hypot',
 'i0',
 'i0_',
 'igamma',
 'igammac',
 'iinfo',
 'imag',
 'import_ir_module',
 'import_ir_module_from_buffer',
 'index_add',
 'index_copy',
 'index_fill',
 'index_put',
 'index_put_',
 'index_select',
 'inf',
 'inference_mode',
 'init_num_threads',
 'initial_seed',
 'inner',
 'instance_norm',
 'int',
 'int16',
 'int32',
 'int64',
 'int8',
 'int_repr',
 'inverse',
 'is_anomaly_enabled',
 'is_autocast_cache_enabled',
 'is_autocast_cpu_enabled',
 'is_autocast_enabled',
 'is_complex',
 'is_conj',
 'is_distributed',
 'is_floating_point',
 'is_grad_enabled',
 'is_inference',
 'is_inference_mode_enabled',
 'is_neg',
 'is_nonzero',
 'is_same_size',
 'is_signed',
 'is_storage',
 'is_tensor',
 'is_vulkan_available',
 'is_warn_always_enabled',
 'isclose',
 'isfinite',
 'isin',
 'isinf',
 'isnan',
 'isneginf',
 'isposinf',
 'isreal',
 'istft',
 'jit',
 'kaiser_window',
 'kl_div',
 'kron',
 'kthvalue',
 'layer_norm',
 'layout',
 'lcm',
 'lcm_',
 'ldexp',
 'ldexp_',
 'le',
 'legacy_contiguous_format',
 'lerp',
 'less',
 'less_equal',
 'lgamma',
 'linalg',
 'linspace',
 'load',
 'lobpcg',
 'log',
 'log10',
 'log10_',
 'log1p',
 'log1p_',
 'log2',
 'log2_',
 'log_',
 'log_softmax',
 'logaddexp',
 'logaddexp2',
 'logcumsumexp',
 'logdet',
 'logical_and',
 'logical_not',
 'logical_or',
 'logical_xor',
 'logit',
 'logit_',
 'logspace',
 'logsumexp',
 'long',
 'lstm',
 'lstm_cell',
 'lstsq',
 'lt',
 'lu',
 'lu_solve',
 'lu_unpack',
 'manual_seed',
 'margin_ranking_loss',
 'masked_fill',
 'masked_scatter',
 'masked_select',
 'matmul',
 'matrix_exp',
 'matrix_power',
 'matrix_rank',
 'max',
 'max_pool1d',
 'max_pool1d_with_indices',
 'max_pool2d',
 'max_pool3d',
 'maximum',
 'mean',
 'median',
 'memory_format',
 'merge_type_from_type_comment',
 'meshgrid',
 'min',
 'minimum',
 'miopen_batch_norm',
 'miopen_convolution',
 'miopen_convolution_transpose',
 'miopen_depthwise_convolution',
 'miopen_rnn',
 'mkldnn_adaptive_avg_pool2d',
 'mkldnn_convolution',
 'mkldnn_convolution_backward_weights',
 'mkldnn_linear_backward_weights',
 'mkldnn_max_pool2d',
 'mkldnn_max_pool3d',
 'mm',
 'mode',
 'moveaxis',
 'movedim',
 'msort',
 'mul',
 'multinomial',
 'multiply',
 'multiprocessing',
 'mv',
 'mvlgamma',
 'name',
 'nan',
 'nan_to_num',
 'nan_to_num_',
 'nanmean',
 'nanmedian',
 'nanquantile',
 'nansum',
 'narrow',
 'narrow_copy',
 'native_batch_norm',
 'native_group_norm',
 'native_layer_norm',
 'native_norm',
 'ne',
 'neg',
 'neg_',
 'negative',
 'negative_',
 'nextafter',
 'nn',
 'no_grad',
 'nonzero',
 'norm',
 'norm_except_dim',
 'normal',
 'not_equal',
 'nuclear_norm',
 'numel',
 'ones',
 'ones_like',
 'onnx',
 'ops',
 'optim',
 'orgqr',
 'ormqr',
 'os',
 'outer',
 'overrides',
 'package',
 'pairwise_distance',
 'parse_ir',
 'parse_schema',
 'parse_type_comment',
 'pca_lowrank',
 'pdist',
 'per_channel_affine',
 'per_channel_affine_float_qparams',
 'per_channel_symmetric',
 'per_tensor_affine',
 'per_tensor_symmetric',
 'permute',
 'pi',
 'pinverse',
 'pixel_shuffle',
 'pixel_unshuffle',
 'platform',
 'poisson',
 'poisson_nll_loss',
 'polar',
 'polygamma',
 'positive',
 'pow',
 'prelu',
 'prepare_multiprocessing_environment',
 'preserve_format',
 'prod',
 'profiler',
 'promote_types',
 'put',
 'q_per_channel_axis',
 'q_per_channel_scales',
 'q_per_channel_zero_points',
 'q_scale',
 'q_zero_point',
 'qint32',
 'qint8',
 'qr',
 'qscheme',
 'quantile',
 'quantization',
 'quantize_per_channel',
 'quantize_per_tensor',
 'quantized_batch_norm',
 'quantized_gru',
 'quantized_gru_cell',
 'quantized_lstm',
 'quantized_lstm_cell',
 'quantized_max_pool1d',
 'quantized_max_pool2d',
 'quantized_rnn_relu_cell',
 'quantized_rnn_tanh_cell',
 'quasirandom',
 'quint4x2',
 'quint8',
 'rad2deg',
 'rad2deg_',
 'rand',
 'rand_like',
 'randint',
 'randint_like',
 'randn',
 'randn_like',
 'random',
 'randperm',
 'range',
 'ravel',
 'read_vitals',
 'real',
 'reciprocal',
 'reciprocal_',
 'relu',
 'relu_',
 'remainder',
 'renorm',
 'repeat_interleave',
 'reshape',
 'resize_as_',
 'resize_as_sparse_',
 'resolve_conj',
 'resolve_neg',
 'result_type',
 'rnn_relu',
 'rnn_relu_cell',
 'rnn_tanh',
 'rnn_tanh_cell',
 'roll',
 'rot90',
 'round',
 'round_',
 'row_stack',
 'rrelu',
 'rrelu_',
 'rsqrt',
 'rsqrt_',
 'rsub',
 'saddmm',
 'save',
 'scalar_tensor',
 'scatter',
 'scatter_add',
 'searchsorted',
 'seed',
 'segment_reduce',
 'select',
 'selu',
 'selu_',
 'serialization',
 'set_anomaly_enabled',
 'set_autocast_cache_enabled',
 'set_autocast_cpu_dtype',
 'set_autocast_cpu_enabled',
 ...]

Then of course we can go further,继续dir(torch.cuda)再去看看torch.cudaWhat are the libraries or functions in ,但是,没啥必要,Because we just want to know right nowtorch.cuda.is_available()函数啥意思,所以,其实前面的dir()steps can be removed,直接help(torch.cuda.is_available)就可以了.

如下图所示:

注意:It is used between the library and the sub-library to the corresponding function " . " 相连的,并且,helpThe scene can give a description of the function,A description of the library can also be given.即:help(torch.cuda) 也是可以的

copyright notice
author[chuanauc],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/218/202208060848299546.html

Random recommended