AI Python for Beginners-Andrew吴恩达-study notes(1)

1 Instroduction

        python becomes more and more important since AI era has come ,  no matter which career you have , you can mostly benefit by using python to write codes for your daily work.

2 What is computer programming?

        python actually seeps into our life ,not only data scientist uses it but some secretaries also use it , and python has a big community itself,so when you meet some problems about python , you can just ask python learners for all over the world for help. 

3 Writing code with chatbots

 completion:the chatbot's response to the prompt

        there will be a chatbot for us in this class to ask questions about python , although it can not write complex questions but it can definitely write some simple code if needs , and we are encouraged to try to learn python with this chatbot.

4 Nevigating the learning platform

5 running your first program

6 how to succeed in coding

        keep on understanding the code and try to think it in another way

7 data in python

(1)different types of data in Python

①strings

②Multiline strings

 

type() function

 To check the data type, you can use the type() function. 

Since there are no quotes("") around the number Python assumes this is numerical data, and since there is no decimal place on this number, it interprets it as an integer. 

as a calculator

8 combining text and calculations

formatted string

9  variables

10 building LLM prompts with variables

by importing the following content , you can just chat with the AI bot in python , and get its reponse in two ways.

11 Functions:Actions on Data

(1)len()

(2)round()

(3)Using functions in AI programs

1. print_llm_response:

  • Purpose: This function would generate a response from the Language Model and print it directly to the console.
  • Use Case: Use this function when you want to see the response immediately and do not need to use the response for further processing within your code.
import openai

openai.api_key = 'your-api-key-here'

def print_llm_response(prompt):
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=prompt,
        max_tokens=100
    )
    print(response.choices[0].text.strip())

# Example usage
print_llm_response("Can you recommend a new song for me to listen to?")

2.get_llm_response:

  • Purpose: This function would generate a response from the Language Model and return it as a value, which you can then use in your program.
  • Use Case: Use this function when you need to use the response for further processing, storage, or any other manipulation within your code.
import openai

openai.api_key = 'your-api-key-here'

def get_llm_response(prompt):
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=prompt,
        max_tokens=100
    )
    return response.choices[0].text.strip()

# Example usage
response = get_llm_response("Can you recommend a new song for me to listen to?")
print(response)

 

To interact with a Language Model (LLM) like OpenAI's GPT, you typically use an API. Here are some basic functions and steps you can use to request help from such models:

1.Install the necessary package: If you're using OpenAI's GPT, you'll need the openai package.

pip install openai

2.Import the package and set your API key: Import the openai package and set your API key to authenticate.

import openai

# Set your OpenAI API key here
openai.api_key = "your-api-key-here"

3.Create a function to ask the LLM for help: You can create a function that sends a request to the model and returns the response.

import openai

# Set your API key here
openai.api_key = 'your-api-key-here'

def ask_llm(prompt):
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=prompt,
        max_tokens=100  # Adjust the max tokens as needed
    )
    return response.choices[0].text.strip()

# Example usage
prompt = "Can you recommend a good book based on my favorite movie, 'Inception'?"
response = ask_llm(prompt)
print(response)

学习网站:

https://learn.deeplearning.ai/courses/ai-python-for-beginners/lesson/1/introduction

  • 19
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 很抱歉,我是一名AI语言模型,无法进行安装操作。但是,我可以提供一些安装ROS Academy for Beginners的指导: 1. 首先,确保你的计算机已经安装了ROS(Robot Operating System)。 2. 在终端中输入以下命令,下载ROS Academy for Beginners: ``` git clone https://github.com/qboticslabs/ros-academy-for-beginners.git ``` 3. 进入下载的文件夹: ``` cd ros-academy-for-beginners ``` 4. 运行安装脚本: ``` ./install.sh ``` 5. 安装完成后,你可以在终端中输入以下命令,启动ROS Academy for Beginners: ``` roslaunch academy academy.launch ``` 希望这些指导能够帮助你安装ROS Academy for Beginners。如果你遇到了任何问题,可以在ROS社区中寻求帮助。 ### 回答2: 首先,安装ROS的前提是已经安装好了Ubuntu操作系统,推荐使用Ubuntu 18.04。可以从Ubuntu的官网上下载系统镜像并且安装。 其次,在安装ROS之前,需要先添加ROS的软件源,这里以Melodic版本为例。打开终端,输入以下命令,添加ROS的软件源: ``` sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' ``` 由于ROS的安装需要与ubuntu操作系统的软件进行整合,为了确保最佳匹配,需要先运行以下命令进行更新: ``` sudo apt update sudo apt upgrade ``` 然后是ROS的安装,运行以下命令: ``` sudo apt install ros-melodic-desktop-full ``` 该命令会安装ROS桌面完整版,其中包含许多常用的软件包和工具。安装完成后,可以通过以下命令检查ROS的版本: ``` rosversion -d ``` 接下来,还需配置ROS环境变量。在终端中输入: ``` echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc ``` 安装ROS的最后一步是安装ROS初始工作区(catkin工作区)。打开终端,输入以下命令: ``` mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ catkin_make ``` 这个命令创建一个名为catkin_ws的文件夹,并在其中创建一个src文件夹,用于存放ROS软件包源代码。 最后,我们可以安装ros-academy-for-beginners这个包,这个包可以用于学习ROS的基础知识,包括ROS的概念、练习和示例等等。在终端输入以下命令: ``` cd ~/catkin_ws/src git clone https://github.com/OTL/ros-academy-for-beginners.git cd ~/catkin_ws catkin_make ``` 至此,ros-academy-for-beginners的安装就完成了。如果想要使用该软件包内的示例和练习程序,可以查看ros-academy-for-beginners中的README文件,然后通过以下命令运行: ``` roslaunch ros_academy_publisher publisher.launch ``` ### 回答3: ROS(机器人操作系统)是一种流行的开源软件框架,它可以帮助开发人员为机器人软件构建底层、中间层、以及可视化的应用程序。ROS Academy for Beginners是一个为初学者提供ROS学习和实践的平台,这个平台包含了一系列的教程,如基础知识、机器人操作、感知和导航等。 在安装ROS Academy for Beginners之前,首先需要准备以下工具: 1. 一个ROS Kinetic(或更高版本)的Ubuntu操作系统。 2. 一个支持VirtualBox或VMware的虚拟机管理软件。 3. 一个ROS学习环境的Ubuntu虚拟机镜像文件。 下面是安装ROS Academy for Beginners的步骤: 1. 在VirtualBox(或其他虚拟机软件)中创建一台新的虚拟机。请确保选择Ubuntu x64的版本。 2. 启动Ubuntu虚拟机,并使用管理员权限运行Terminal。 3. 输入以下命令,添加ROS Kinetic的存储库以及密钥: $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' $ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 4. 更新存储库并安装ROS Kinetic Desktop Full: $ sudo apt-get update $ sudo apt-get install ros-kinetic-desktop-full 5. 安装ROS依赖项: $ sudo apt-get install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential 6. 初始化rosdep: $ sudo rosdep init $ rosdep update 7. 设置ROS环境变量: $ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc $ source ~/.bashrc 8. 下载ROS Academy for Beginners虚拟机镜像: $ wget https://s3-us-west-2.amazonaws.com/ros-academy/ROS-Academy-For-Beginners.ova 9. 启动VirtualBox软件,选择“File” -> “Import Appliance”,并选择已下载的ROS Academy for Beginners虚拟机镜像文件。 10. 等待虚拟机导入完成后,启动ROS Academy for Beginners虚拟机,并按照教程开始学习ROS! 希望这些步骤可以帮助您安装ROS Academy for Beginners。如果您在安装过程中遇到任何问题,请参考ROS官方文档或社区论坛,寻求帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值