Commit 72567f0f by Leo

upload code

parent be6afc29
找班主任领取学习星球打卡表
找班主任领取学习星球打卡表
\ No newline at end of file
AI环境配置作业,完成github上unet-zoo的环境搭建,需要安装如下包:matplotlib、sklearn、skimage、cv2、pandas
AI环境配置作业,完成github上unet-zoo的环境搭建,需要安装如下包:matplotlib、sklearn、skimage、cv2、pandas
项目链接:https://github.com/Andy-zhujunwen/UNET-ZOO
作业要求:完成后需要截图显示相关的包
\ No newline at end of file
{
{
"cells": [
{
"cell_type": "markdown",
"id": "61a7b47c",
"metadata": {},
"source": [
"打印九九乘法表\n",
"使用 for 循环打印九九乘法表:\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "aedd2f1b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1x1=1\t\n",
"1x2=2\t2x2=4\t\n",
"1x3=3\t2x3=6\t3x3=9\t\n",
"1x4=4\t2x4=8\t3x4=12\t4x4=16\t\n",
"1x5=5\t2x5=10\t3x5=15\t4x5=20\t5x5=25\t\n",
"1x6=6\t2x6=12\t3x6=18\t4x6=24\t5x6=30\t6x6=36\t\n",
"1x7=7\t2x7=14\t3x7=21\t4x7=28\t5x7=35\t6x7=42\t7x7=49\t\n",
"1x8=8\t2x8=16\t3x8=24\t4x8=32\t5x8=40\t6x8=48\t7x8=56\t8x8=64\t\n",
"1x9=9\t2x9=18\t3x9=27\t4x9=36\t5x9=45\t6x9=54\t7x9=63\t8x9=72\t9x9=81\t\n"
]
}
],
"source": [
"# 九九乘法表\n",
"for i in range(1, 10): # 控制行:1 到 9\n",
" for j in range(1, i + 1): # 控制列:每行打印 i 个乘法\n",
" print(f\"{j}x{i}={j*i}\", end=\"\\t\") # 打印一个乘法项,\\t表示制表符\n",
" print() # 换行\n"
]
},
{
"cell_type": "markdown",
"id": "0ceff9ac",
"metadata": {},
"source": [
"判断奇偶数\n",
"用户输入一个整数,判断是奇数还是偶数,并输出结果。"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c9842a75",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12 是偶数。\n"
]
}
],
"source": [
"# 判断奇偶数\n",
"\n",
"num = int(input(\"请输入一个整数:\"))\n",
"\n",
"if num % 2 == 0:\n",
" print(f\"{num} 是偶数。\")\n",
"else:\n",
" print(f\"{num} 是奇数。\")\n"
]
},
{
"cell_type": "markdown",
"id": "9a49b317",
"metadata": {},
"source": [
"计算阶乘\n",
"输入一个正整数 n,计算 n!(例如 5! = 5×4×3×2×1)。"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "3f622091",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5! = 120\n"
]
}
],
"source": [
"# 计算阶乘(n!)\n",
"\n",
"n = int(input(\"请输入一个正整数:\"))\n",
"\n",
"if n < 0:\n",
" print(\"请输入非负整数。\")\n",
"elif n == 0 or n == 1:\n",
" print(f\"{n}! = 1\")\n",
"else:\n",
" factorial = 1\n",
" for i in range(2, n + 1):\n",
" factorial *= i\n",
" print(f\"{n}! = {factorial}\")\n"
]
},
{
"cell_type": "markdown",
"id": "5455b738",
"metadata": {},
"source": [
"列表去重\n",
"给定一个列表 lst = [1, 2, 2, 3, 4, 4, 5],去除重复元素并保持原有顺序。"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "9b9394ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"去重后的列表: [1, 2, 3, 4, 5]\n"
]
}
],
"source": [
"# 原始列表\n",
"lst = [1, 2, 2, 3, 4, 4, 5]\n",
"\n",
"# 去重但保持顺序\n",
"result = []\n",
"for item in lst:\n",
" if item not in result:\n",
" result.append(item)\n",
"\n",
"print(\"去重后的列表:\", result)\n"
]
},
{
"cell_type": "markdown",
"id": "6e1fc270",
"metadata": {},
"source": [
"倒序输出列表\n",
"给定一个列表 [1, 2, 3, 4, 5],请倒序输出(不能使用内置函数 reverse())。"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f2738a00",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"倒序列表: [5, 4, 3, 2, 1]\n"
]
}
],
"source": [
"# 倒序输出\n",
"lst = [1, 2, 3, 4, 5]\n",
"reversed_lst = lst[::-1]\n",
"print(\"倒序列表:\", reversed_lst)\n"
]
},
{
"cell_type": "markdown",
"id": "93a54592",
"metadata": {},
"source": [
"实现一个 BankAccount 类,支持存款、取款和查询余额操作。"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d29afaa4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"小明 存入了 500 元。当前余额:1500 元。\n",
"小明 取出了 300 元。当前余额:1200 元。\n",
"小明 当前余额为:1200 元。\n",
"余额不足,无法取款。\n"
]
}
],
"source": [
"class BankAccount:\n",
" def __init__(self, owner, balance=0):\n",
" self.owner = owner\n",
" self.balance = balance\n",
"\n",
" def deposit(self, amount):\n",
" if amount <= 0:\n",
" print(\"存款金额必须大于0。\")\n",
" else:\n",
" self.balance += amount\n",
" print(f\"{self.owner} 存入了 {amount} 元。当前余额:{self.balance} 元。\")\n",
"\n",
" def withdraw(self, amount):\n",
" if amount <= 0:\n",
" print(\"取款金额必须大于0。\")\n",
" elif amount > self.balance:\n",
" print(\"余额不足,无法取款。\")\n",
" else:\n",
" self.balance -= amount\n",
" print(f\"{self.owner} 取出了 {amount} 元。当前余额:{self.balance} 元。\")\n",
"\n",
" def get_balance(self):\n",
" print(f\"{self.owner} 当前余额为:{self.balance} 元。\")\n",
" return self.balance\n",
"\n",
"# 使用示例\n",
"if __name__ == \"__main__\":\n",
" account = BankAccount(\"小明\", 1000) # 初始余额为1000元\n",
" account.deposit(500) # 存款\n",
" account.withdraw(300) # 取款\n",
" account.get_balance() # 查询余额\n",
" account.withdraw(2000) # 超额取款测试\n"
]
},
{
"cell_type": "markdown",
"id": "88ee9c01",
"metadata": {},
"source": [
"暂停一秒输出。\n",
"使用 time 模块的 sleep() 函数。"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "925c7b3b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"输出第 1 个数字\n",
"输出第 2 个数字\n",
"输出第 3 个数字\n",
"输出第 4 个数字\n",
"输出第 5 个数字\n"
]
}
],
"source": [
"import time\n",
"\n",
"for i in range(5):\n",
" print(f\"输出第 {i+1} 个数字\")\n",
" time.sleep(1) # 暂停1秒\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "test",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
{
"cells": [
{
"cell_type": "markdown",
"id": "61a7b47c",
"metadata": {},
"source": [
" 一、基础语法\n",
"打印九九乘法表\n",
"使用 for 循环打印九九乘法表:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aedd2f1b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "0ceff9ac",
"metadata": {},
"source": [
"判断奇偶数\n",
"用户输入一个整数,判断是奇数还是偶数,并输出结果。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c9842a75",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "9a49b317",
"metadata": {},
"source": [
"计算阶乘\n",
"输入一个正整数 n,计算 n!(例如 5! = 5×4×3×2×1)。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3f622091",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "5455b738",
"metadata": {},
"source": [
"列表去重\n",
"给定一个列表 lst = [1, 2, 2, 3, 4, 4, 5],去除重复元素并保持原有顺序。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9b9394ec",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "6e1fc270",
"metadata": {},
"source": [
"倒序输出列表\n",
"给定一个列表 [1, 2, 3, 4, 5],请倒序输出(不能使用内置函数 reverse())。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2738a00",
"metadata": {},
"outputs": [],
"source": [
"# 倒序输出"
]
},
{
"cell_type": "markdown",
"id": "93a54592",
"metadata": {},
"source": [
"实现一个 BankAccount 类,支持存款、取款和查询余额操作。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d29afaa4",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "88ee9c01",
"metadata": {},
"source": [
"暂停一秒输出。\n",
"使用 time 模块的 sleep() 函数。"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "925c7b3b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "test",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
python基础题目:题目需完成80%往上
python基础题目:题目需完成80%往上
\ No newline at end of file
#人工智能课程项目作业说明
#人工智能课程项目作业说明
项目名称:vit图像分类项目
Tips:核心代码在examples文件夹下的cats_and_dogs.ipynb
#一、项目背景
本项目将实现Vision Transformer(ViT)模型,完成图像分类任务。通过将图像分割为序列块并应用Transformer架构,你将掌握:
·图像块嵌入(Patch Embedding)的实现方式
·Transformer Encoder在CV领域的应用
·位置编码(Positional Encoding)对空间信息的保留
·与传统CNN模型的结构差异分析
#二、任务要求
1.环境配置:根据项目readme完成项目环境的配置
2.项目运行:需要完成数据的处理、模型训练、推理图片
3.代码注释:用中文详细注释核心代码每个模块功能
#三、提交说明
将项目运行保存并打包压缩发给你的班主任,压缩包的名称请以学号和昵称命名哦~
Tips:学号不知道的可以联系班主任哈!
\ No newline at end of file
#项目链接
#项目链接
vit-pytorch.zip
链接: https://pan.baidu.com/s/1W1X5Rh7l9r8XUS8Jmb1H_Q?pwd=q21a
提取码: q21a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment