-- Learning not just technology, but dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
PyTorch Tutorial
PyTorch TutorialPyTorch IntroductionPyTorch InstallationPyTorch BasicsPyTorch TensorsPyTorch Neural Network BasicsPyTorch First Neural NetworkPyTorch Data Processing and LoadingPyTorch Linear RegressionPyTorch Convolutional Neural NetworkPyTorch Recurrent Neural NetworkPyTorch DatasetsPyTorch Data TransformsPytorch torch ReferencePyTorch torch.nn ReferenceTransformer ModelPyTorch Building Transformer ModelPyTorch torch.optim Optimizer ModulePyTorch torchvision Computer Vision ModulePyTorch Model DeploymentPyTorch Model Saving and LoadingPyTorch Example β Image Classification ProjectPyTorch Text Sentiment AnalysisPyTorch AutogradPyTorch GPU / CUDA AccelerationPyTorch Loss FunctionsPyTorch Learning Rate SchedulerPyTorch Transfer LearningPyTorch Batch NormalizationPyTorch LSTM / GRUPyTorch Word EmbeddingPyTorch Generative Adversarial NetworkPyTorch AutoencoderPyTorch Model Evaluation and DebuggingPyTorch torchtextPyTorch Mixed Precision TrainingPyTorch TorchScript/ONNX ExportPyTorch Distributed TrainingPyTorch Attention Mechanism
PyTorch torch.ones_like Function
torch.ones_like is a function in PyTorch used to create a tensor filled with ones that has the same shape as the input tensor.
Function Definition
torch.ones_like(input, dtype=None, device=None, requires_grad=False)
Usage Example
Example
import torch
x = torch.randn(2,3)
y = torch.ones_like(x)
print(y)
Output result:
tensor([[1., 1., 1.], [1., 1., 1.]])
YouTip