first commit

This commit is contained in:
2025-11-07 15:07:57 +08:00
commit 45b9467c0b
7 changed files with 2288 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.11

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# AI Learning
My AI Learning repository based on PyTorch and Astral UV.

View File

@ -0,0 +1,37 @@
import torch
def main():
print('===== Chapter 1 =====')
chapter_1()
def chapter_1():
x = torch.arange(12)
print(f'x: {x}')
print(f'x.shape: {x.shape}')
print(f'x.numel(): {x.numel()}')
xs = x.reshape(3, 4)
print(f'x.reshape: {xs}')
xs = x.reshape(-1, 4)
print(f'x.reshape auto 1: {xs}')
xs = x.reshape(3, -1)
print(f'x.reshape auto 2: {xs}')
zeros = torch.zeros((2, 3, 4))
print(f'zeros: {zeros}')
ones = torch.ones((2, 3, 4))
print(f'ones: {ones}')
randoms = torch.randn(3, 4)
print(f'randn: {randoms}')
manual = torch.tensor([[2, 1, 4, 3], [1, 2, 3, 4], [4, 3, 2, 1]])
print(f'manual: {manual}')
# 看起来reshape第一个是行数
manual = torch.tensor([2, 1, 4, 3, 1, 2, 3, 4, 4, 3, 2, 1]).reshape(3, -1)
print(f'manual: {manual}')
if __name__ == "__main__":
main()

6
main.py Normal file
View File

@ -0,0 +1,6 @@
def main():
print("Hello from learning!")
if __name__ == "__main__":
main()

26
pyproject.toml Normal file
View File

@ -0,0 +1,26 @@
[project]
name = "learning"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"datasets>=4.3.0",
"matplotlib>=3.10.7",
"numpy>=2.3.4",
"torch>=2.9.0",
"torchvision>=0.24.0",
]
[tool.uv.sources]
torch = [
{ index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
torchvision = [
{ index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
[[tool.uv.index]]
name = "pytorch-cu126"
url = "https://download.pytorch.org/whl/cu126"
explicit = true

2205
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff