1. บทนำสู่ปัญญาประดิษฐ์ (Introduction to Artificial Intelligence)

1.1 ความหมายและนิยามของปัญญาประดิษฐ์ (Definition of AI)

1.1.1 ปัญญาประดิษฐ์คืออะไร?

ปัญญาประดิษฐ์ (Artificial Intelligence: AI) คือ สาขาวิชาทางวิทยาการคอมพิวเตอร์ที่มุ่งเน้นการสร้างระบบหรือเครื่องจักรที่สามารถแสดงพฤติกรรมอัจฉริยะ โดยสามารถ รับรู้ (Perceive) สิ่งแวดล้อม เรียนรู้ (Learn) จากประสบการณ์ ตัดสินใจ (Decide) และ กระทำ (Act) เพื่อบรรลุเป้าหมายที่กำหนด

นิยามของ AI สามารถแบ่งออกได้เป็น 4 แนวทางหลัก:

แนวทาง คำอธิบาย ตัวอย่าง
Thinking Humanly ระบบที่คิดเหมือนมนุษย์ Cognitive Science, Neural Networks
Thinking Rationally ระบบที่คิดอย่างมีเหตุผล Logic-based AI, Expert Systems
Acting Humanly ระบบที่กระทำเหมือนมนุษย์ Turing Test, Chatbots
Acting Rationally ระบบที่กระทำอย่างมีเหตุผล Rational Agents, Optimization

1.1.2 การทดสอบทัวริง (Turing Test)

การทดสอบทัวริง เสนอโดย Alan Turing ในปี 1950 เป็นวิธีการทดสอบว่าเครื่องจักรมีความฉลาดหรือไม่ โดยหากมนุษย์ไม่สามารถแยกแยะได้ว่ากำลังสนทนากับมนุษย์หรือเครื่องจักร แสดงว่าเครื่องจักรนั้นผ่านการทดสอบ

flowchart LR
    subgraph Test["การทดสอบทัวริง (Turing Test)"]
        A["ผู้ถาม
(Interrogator)"] -->|"ส่งคำถาม"| B["หน้าจอ
(Screen)"] B -->|"รับคำตอบ"| A C["มนุษย์
(Human)"] -->|"ตอบ"| B D["เครื่องจักร
(Machine)"] -->|"ตอบ"| B end style A fill:#458588,stroke:#282828,color:#ebdbb2 style B fill:#d79921,stroke:#282828,color:#282828 style C fill:#98971a,stroke:#282828,color:#282828 style D fill:#cc241d,stroke:#282828,color:#ebdbb2

ความสามารถที่เครื่องจักรต้องมีเพื่อผ่านการทดสอบทัวริง:


1.2 ประวัติและวิวัฒนาการของ AI (History and Evolution of AI)

1.2.1 ไทม์ไลน์การพัฒนา AI

flowchart TB
    subgraph Era1["ยุคบุกเบิก (1943-1956)"]
        A1["1943: McCulloch-Pitts
Neural Network Model"] --> A2["1950: Turing Test
Alan Turing"] A2 --> A3["1956: Dartmouth Conference
กำเนิดคำว่า AI"] end subgraph Era2["ยุคทอง (1956-1974)"] B1["1958: LISP
John McCarthy"] --> B2["1966: ELIZA
Chatbot แรก"] B2 --> B3["1969: SHAKEY
หุ่นยนต์เคลื่อนที่"] end subgraph Era3["ยุค AI Winter (1974-1993)"] C1["1974: ขาดเงินทุน
ผลลัพธ์ไม่เป็นไปตามคาด"] --> C2["1980s: Expert Systems
ระบบผู้เชี่ยวชาญ"] C2 --> C3["1987: AI Winter ครั้งที่ 2
ตลาดล่มสลาย"] end subgraph Era4["ยุคฟื้นฟู (1993-2011)"] D1["1997: Deep Blue
ชนะแชมป์หมากรุก"] --> D2["2006: Deep Learning
Geoffrey Hinton"] D2 --> D3["2011: Watson
ชนะ Jeopardy!"] end subgraph Era5["ยุคปัจจุบัน (2012-Now)"] E1["2012: AlexNet
Image Recognition"] --> E2["2016: AlphaGo
ชนะแชมป์โกะ"] E2 --> E3["2022: ChatGPT
Large Language Models"] E3 --> E4["2024: AI Agents
Multimodal AI"] end Era1 --> Era2 --> Era3 --> Era4 --> Era5 style A1 fill:#458588,stroke:#282828,color:#ebdbb2 style A2 fill:#458588,stroke:#282828,color:#ebdbb2 style A3 fill:#458588,stroke:#282828,color:#ebdbb2 style B1 fill:#98971a,stroke:#282828,color:#282828 style B2 fill:#98971a,stroke:#282828,color:#282828 style B3 fill:#98971a,stroke:#282828,color:#282828 style C1 fill:#cc241d,stroke:#282828,color:#ebdbb2 style C2 fill:#cc241d,stroke:#282828,color:#ebdbb2 style C3 fill:#cc241d,stroke:#282828,color:#ebdbb2 style D1 fill:#d79921,stroke:#282828,color:#282828 style D2 fill:#d79921,stroke:#282828,color:#282828 style D3 fill:#d79921,stroke:#282828,color:#282828 style E1 fill:#b16286,stroke:#282828,color:#ebdbb2 style E2 fill:#b16286,stroke:#282828,color:#ebdbb2 style E3 fill:#b16286,stroke:#282828,color:#ebdbb2 style E4 fill:#b16286,stroke:#282828,color:#ebdbb2

1.2.2 เหตุการณ์สำคัญในประวัติศาสตร์ AI

ปี เหตุการณ์ ความสำคัญ
1943 McCulloch-Pitts Model โมเดลคณิตศาสตร์แรกของเซลล์ประสาท
1950 Turing Test มาตรฐานการวัดความฉลาดของเครื่อง
1956 Dartmouth Conference ถือกำเนิดสาขา AI อย่างเป็นทางการ
1997 Deep Blue vs Kasparov AI ชนะแชมป์หมากรุกโลก
2012 AlexNet การปฏิวัติ Deep Learning
2017 Transformer สถาปัตยกรรมพื้นฐานของ LLMs
2022 ChatGPT AI สนทนาเข้าถึงมวลชน

1.3 สาขาต่าง ๆ ของ AI (Branches of AI)

mindmap
    root((ปัญญาประดิษฐ์
AI)) Machine Learning Supervised Learning Unsupervised Learning Reinforcement Learning Deep Learning Computer Vision Image Classification Object Detection Face Recognition Image Segmentation Natural Language Processing Text Classification Machine Translation Chatbots Sentiment Analysis Robotics Motion Planning Manipulation Autonomous Navigation Human-Robot Interaction Expert Systems Knowledge Base Inference Engine Rule-Based Systems Speech Recognition Voice Assistants Speech-to-Text Text-to-Speech

1.3.1 การเรียนรู้ของเครื่อง (Machine Learning)

Machine Learning (ML) คือ สาขาย่อยของ AI ที่มุ่งเน้นการพัฒนาอัลกอริทึมที่สามารถ เรียนรู้รูปแบบ (Pattern) จากข้อมูล และ ทำนาย (Predict) หรือตัดสินใจโดยไม่ต้องเขียนโปรแกรมอย่างชัดเจน

ประเภทหลักของ Machine Learning:

  1. การเรียนรู้แบบมีผู้สอน (Supervised Learning)

  2. การเรียนรู้แบบไม่มีผู้สอน (Unsupervised Learning)

  3. การเรียนรู้แบบเสริมกำลัง (Reinforcement Learning)

"""
ตัวอย่าง: การจำแนกประเภท (Classification) ด้วย scikit-learn
การเรียนรู้แบบมีผู้สอนเพื่อจำแนกดอกไอริส
"""

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score

# โหลดข้อมูลตัวอย่าง (Iris Dataset)
iris = load_iris()
X = iris.data      # คุณลักษณะ (Features): ความยาว/ความกว้างของกลีบดอก
y = iris.target    # ป้ายกำกับ (Labels): สายพันธุ์ของดอกไอริส

# แบ่งข้อมูลสำหรับฝึกและทดสอบ (80% train, 20% test)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# สร้างและฝึกโมเดล Decision Tree
model = DecisionTreeClassifier(max_depth=3)
model.fit(X_train, y_train)  # ฝึกโมเดลด้วยข้อมูล train

# ทำนายผลลัพธ์
y_pred = model.predict(X_test)

# วัดความแม่นยำ
accuracy = accuracy_score(y_test, y_pred)
print(f"ความแม่นยำของโมเดล: {accuracy:.2%}")

# ตัวอย่างการใช้งาน
# Output: ความแม่นยำของโมเดล: 100.00%

1.3.2 การมองเห็นด้วยคอมพิวเตอร์ (Computer Vision)

Computer Vision คือ สาขาที่ทำให้คอมพิวเตอร์สามารถ ตีความและเข้าใจภาพ หรือวิดีโอ เหมือนกับที่มนุษย์มองเห็น

งานหลักใน Computer Vision:

"""
ตัวอย่าง: การตรวจจับขอบภาพด้วย OpenCV
พื้นฐาน Computer Vision ในการประมวลผลภาพ
"""

import cv2
import numpy as np

def detect_edges(image_path: str, threshold1: int = 100, threshold2: int = 200):
    """
    ตรวจจับขอบภาพด้วย Canny Edge Detection
    
    Args:
        image_path: เส้นทางไปยังไฟล์ภาพ
        threshold1: ค่าขีดแบ่งต่ำสุด
        threshold2: ค่าขีดแบ่งสูงสุด
    
    Returns:
        ภาพที่แสดงขอบที่ตรวจจับได้
    """
    # อ่านภาพเป็นโทนสีเทา (Grayscale)
    image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
    
    # ลด Noise ด้วย Gaussian Blur
    blurred = cv2.GaussianBlur(image, (5, 5), 0)
    
    # ตรวจจับขอบด้วย Canny Algorithm
    edges = cv2.Canny(blurred, threshold1, threshold2)
    
    return edges

# ตัวอย่างการใช้งาน
# edges = detect_edges("sample_image.jpg")
# cv2.imwrite("edges_output.jpg", edges)

1.3.3 การประมวลผลภาษาธรรมชาติ (Natural Language Processing)

Natural Language Processing (NLP) คือ สาขาที่ทำให้คอมพิวเตอร์สามารถ เข้าใจ ตีความ และสร้างภาษามนุษย์ ได้

flowchart LR
    subgraph Input["ข้อมูลนำเข้า"]
        A["ข้อความดิบ
(Raw Text)"] end subgraph Process["กระบวนการ NLP"] B["Tokenization
แบ่งคำ"] --> C["Preprocessing
ทำความสะอาด"] C --> D["Feature Extraction
สกัดคุณลักษณะ"] D --> E["Model
โมเดล ML/DL"] end subgraph Output["ผลลัพธ์"] F["Classification
จำแนก"] G["Translation
แปลภาษา"] H["Generation
สร้างข้อความ"] end A --> B E --> F E --> G E --> H style A fill:#458588,stroke:#282828,color:#ebdbb2 style B fill:#98971a,stroke:#282828,color:#282828 style C fill:#98971a,stroke:#282828,color:#282828 style D fill:#98971a,stroke:#282828,color:#282828 style E fill:#d79921,stroke:#282828,color:#282828 style F fill:#b16286,stroke:#282828,color:#ebdbb2 style G fill:#b16286,stroke:#282828,color:#ebdbb2 style H fill:#b16286,stroke:#282828,color:#ebdbb2

งานหลักใน NLP:

1.3.4 หุ่นยนต์ (Robotics)

Robotics คือ สาขาที่ผสมผสาน AI กับวิศวกรรมเครื่องกล เพื่อสร้าง เครื่องจักรอัตโนมัติ ที่สามารถทำงานในโลกจริงได้

องค์ประกอบหลักของหุ่นยนต์อัจฉริยะ:


1.4 ประเภทของ AI: Weak AI vs Strong AI

1.4.1 AI แบบแคบ (Narrow AI / Weak AI)

Narrow AI หรือ Weak AI คือ ระบบ AI ที่ถูกออกแบบและฝึกมาเพื่อทำ งานเฉพาะทาง เพียงอย่างเดียว ไม่มีความเข้าใจหรือจิตสำนึกที่แท้จริง

ตัวอย่าง Narrow AI ในปัจจุบัน:

1.4.2 AI แบบทั่วไป (General AI / Strong AI)

General AI หรือ Strong AI หรือ Artificial General Intelligence (AGI) คือ ระบบ AI สมมติที่มีความสามารถทาง สติปัญญาเทียบเท่ามนุษย์ สามารถเรียนรู้และทำงานได้ทุกประเภท

ลักษณะ Narrow AI General AI
ขอบเขตงาน งานเฉพาะทาง งานทั่วไปทุกประเภท
การเรียนรู้ จำกัดเฉพาะโดเมน ถ่ายโอนความรู้ข้ามโดเมน
ความเข้าใจ ไม่มีความเข้าใจจริง มีความเข้าใจเชิงลึก
จิตสำนึก ไม่มี อาจมี (ยังเป็นที่ถกเถียง)
สถานะ มีอยู่ในปัจจุบัน ยังไม่มีอยู่จริง

1.4.3 Super AI

Super AI หรือ Artificial Superintelligence (ASI) คือ แนวคิดเชิงทฤษฎีของ AI ที่มีความฉลาด เหนือกว่ามนุษย์ทุกด้าน รวมถึงความคิดสร้างสรรค์ การแก้ปัญหา และปฏิสัมพันธ์ทางสังคม

flowchart TB
    subgraph Levels["ระดับของปัญญาประดิษฐ์"]
        direction TB
        A["Narrow AI
(ANI)
งานเฉพาะทาง"] --> B["General AI
(AGI)
เทียบเท่ามนุษย์"] B --> C["Super AI
(ASI)
เหนือมนุษย์"] end D["สถานะปัจจุบัน:
เราอยู่ที่นี่"] -.-> A style A fill:#98971a,stroke:#282828,color:#282828 style B fill:#d79921,stroke:#282828,color:#282828 style C fill:#cc241d,stroke:#282828,color:#ebdbb2 style D fill:#458588,stroke:#282828,color:#ebdbb2

1.5 ตัวแทนอัจฉริยะและสิ่งแวดล้อม (Intelligent Agents and Environment)

1.5.1 นิยามของตัวแทนอัจฉริยะ (Intelligent Agent)

ตัวแทน (Agent) คือ สิ่งใดก็ตามที่สามารถ รับรู้ (Perceive) สิ่งแวดล้อมผ่านเซ็นเซอร์ และ กระทำ (Act) ต่อสิ่งแวดล้อมผ่านแอคชูเอเตอร์

ตัวแทนอัจฉริยะ (Intelligent Agent) คือ ตัวแทนที่กระทำอย่าง มีเหตุผล (Rational) เพื่อบรรลุเป้าหมายที่ดีที่สุด

flowchart LR
    subgraph Environment["สิ่งแวดล้อม (Environment)"]
        E["สถานะโลก
(World State)"] end subgraph Agent["ตัวแทน (Agent)"] S["เซ็นเซอร์
(Sensors)"] --> P["การรับรู้
(Percepts)"] P --> D["การตัดสินใจ
(Decision)"] D --> A["การกระทำ
(Actions)"] A --> Act["แอคชูเอเตอร์
(Actuators)"] end E -->|"รับรู้"| S Act -->|"กระทำ"| E style E fill:#689d6a,stroke:#282828,color:#282828 style S fill:#458588,stroke:#282828,color:#ebdbb2 style P fill:#458588,stroke:#282828,color:#ebdbb2 style D fill:#d79921,stroke:#282828,color:#282828 style A fill:#cc241d,stroke:#282828,color:#ebdbb2 style Act fill:#cc241d,stroke:#282828,color:#ebdbb2

ฟังก์ชันของตัวแทน (Agent Function) สามารถแสดงได้ดังนี้:

f : P A

โดยที่:

1.5.2 โครงสร้างของตัวแทน (Agent Structure)

Agent = Architecture + Program

องค์ประกอบ คำอธิบาย ตัวอย่าง
Architecture แพลตฟอร์มทางกายภาพ คอมพิวเตอร์, หุ่นยนต์, สมาร์ทโฟน
Program ซอฟต์แวร์ที่ทำให้เกิดพฤติกรรม อัลกอริทึม AI, โมเดล ML

1.5.3 ประเภทของตัวแทน (Types of Agents)

  1. Simple Reflex Agent

  2. Model-Based Reflex Agent

  3. Goal-Based Agent

  4. Utility-Based Agent

  5. Learning Agent

flowchart TB
    subgraph Types["ประเภทของตัวแทน (Types of Agents)"]
        A["Simple Reflex
ตอบสนองอย่างง่าย"] --> B["Model-Based
มีโมเดลภายใน"] B --> C["Goal-Based
มีเป้าหมาย"] C --> D["Utility-Based
มีฟังก์ชัน Utility"] D --> E["Learning Agent
เรียนรู้ได้"] end F["ความซับซ้อน
เพิ่มขึ้น"] -.-> Types style A fill:#98971a,stroke:#282828,color:#282828 style B fill:#689d6a,stroke:#282828,color:#282828 style C fill:#458588,stroke:#282828,color:#ebdbb2 style D fill:#d79921,stroke:#282828,color:#282828 style E fill:#b16286,stroke:#282828,color:#ebdbb2 style F fill:#504945,stroke:#282828,color:#ebdbb2
"""
ตัวอย่าง: Simple Reflex Agent
ตัวแทนแบบตอบสนองอย่างง่ายสำหรับหุ่นยนต์ดูดฝุ่น
"""

class SimpleReflexVacuumAgent:
    """
    ตัวแทนหุ่นยนต์ดูดฝุ่นแบบ Simple Reflex
    ทำงานในสิ่งแวดล้อม 2 ห้อง (A และ B)
    """
    
    def __init__(self):
        """กำหนดค่าเริ่มต้น"""
        self.location = 'A'  # ตำแหน่งเริ่มต้น
    
    def perceive(self, environment: dict) -> tuple:
        """
        รับรู้สถานะปัจจุบัน
        
        Args:
            environment: สถานะความสะอาดของแต่ละห้อง
        
        Returns:
            tuple ของ (ตำแหน่ง, สถานะความสะอาด)
        """
        status = environment[self.location]
        return (self.location, status)
    
    def act(self, percept: tuple) -> str:
        """
        เลือกการกระทำตามกฎ if-then
        
        Args:
            percept: การรับรู้ปัจจุบัน (ตำแหน่ง, สถานะ)
        
        Returns:
            การกระทำที่เลือก
        """
        location, status = percept
        
        # กฎที่ 1: ถ้าสกปรก ให้ดูดฝุ่น
        if status == 'Dirty':
            return 'Suck'
        # กฎที่ 2: ถ้าอยู่ห้อง A ให้ไปห้อง B
        elif location == 'A':
            return 'Right'
        # กฎที่ 3: ถ้าอยู่ห้อง B ให้ไปห้อง A
        else:
            return 'Left'

# ตัวอย่างการใช้งาน
agent = SimpleReflexVacuumAgent()
environment = {'A': 'Dirty', 'B': 'Clean'}

percept = agent.perceive(environment)
action = agent.act(percept)

print(f"ตำแหน่ง: {percept[0]}, สถานะ: {percept[1]}")
print(f"การกระทำ: {action}")

# Output:
# ตำแหน่ง: A, สถานะ: Dirty
# การกระทำ: Suck

1.5.4 คุณสมบัติของสิ่งแวดล้อม (Properties of Environments)

คุณสมบัติ คำอธิบาย ตัวอย่าง
Fully Observable vs Partially Observable เห็นสถานะทั้งหมดหรือบางส่วน หมากรุก vs โป๊กเกอร์
Deterministic vs Stochastic ผลลัพธ์แน่นอนหรือไม่แน่นอน หมากรุก vs ขับรถ
Episodic vs Sequential แต่ละ Episode แยกกันหรือต่อเนื่อง จำแนกภาพ vs หมากรุก
Static vs Dynamic สิ่งแวดล้อมนิ่งหรือเปลี่ยนแปลง Crossword vs ขับรถ
Discrete vs Continuous สถานะแยกส่วนหรือต่อเนื่อง หมากรุก vs ขับรถ
Single Agent vs Multi-Agent ตัวแทนเดียวหรือหลายตัว Sudoku vs หมากรุก

1.6 จริยธรรมและผลกระทบของ AI (Ethics and Impact of AI)

1.6.1 ประเด็นจริยธรรมหลัก (Key Ethical Issues)

mindmap
    root((จริยธรรม AI
AI Ethics)) ความเป็นธรรม Bias ในข้อมูล การเลือกปฏิบัติ ความเท่าเทียม ความโปร่งใส Explainable AI Black Box Problem การตรวจสอบได้ ความเป็นส่วนตัว การเก็บข้อมูล การใช้ข้อมูล สิทธิ์ในข้อมูล ความรับผิดชอบ ใครรับผิดชอบ? การตัดสินใจ AI ความเสียหาย ความปลอดภัย AI Safety Alignment Problem Control Problem ผลกระทบสังคม การว่างงาน ความเหลื่อมล้ำ การพึ่งพา AI

1.6.2 ความลำเอียง (Bias) ใน AI

Algorithmic Bias เกิดขึ้นเมื่อระบบ AI สร้างผลลัพธ์ที่ ไม่เป็นธรรม หรือ เลือกปฏิบัติ ต่อกลุ่มบุคคลบางกลุ่ม

แหล่งที่มาของ Bias:

"""
ตัวอย่าง: การตรวจสอบ Bias ในโมเดล Classification
แสดงการวิเคราะห์ความเป็นธรรมของโมเดล
"""

import numpy as np
from sklearn.metrics import confusion_matrix

def calculate_fairness_metrics(y_true: np.ndarray, 
                                y_pred: np.ndarray, 
                                sensitive_attr: np.ndarray) -> dict:
    """
    คำนวณเมทริกความเป็นธรรมของโมเดล
    
    Args:
        y_true: ค่าจริง
        y_pred: ค่าทำนาย
        sensitive_attr: คุณลักษณะที่ต้องการตรวจสอบ (เช่น เพศ, เชื้อชาติ)
    
    Returns:
        dict ที่มีเมทริกความเป็นธรรมต่างๆ
    """
    results = {}
    unique_groups = np.unique(sensitive_attr)
    
    for group in unique_groups:
        # แยกข้อมูลตามกลุ่ม
        mask = sensitive_attr == group
        y_true_group = y_true[mask]
        y_pred_group = y_pred[mask]
        
        # คำนวณ True Positive Rate (TPR)
        tn, fp, fn, tp = confusion_matrix(y_true_group, y_pred_group).ravel()
        tpr = tp / (tp + fn) if (tp + fn) > 0 else 0
        
        # คำนวณ Positive Prediction Rate
        ppr = np.mean(y_pred_group)
        
        results[group] = {
            'TPR': tpr,           # อัตราการทำนายถูกต้องสำหรับกลุ่มบวก
            'PPR': ppr,           # อัตราการทำนายเป็นบวก
            'Count': np.sum(mask) # จำนวนข้อมูลในกลุ่ม
        }
    
    # คำนวณ Demographic Parity (ความแตกต่างของ PPR)
    pprs = [v['PPR'] for v in results.values()]
    results['Demographic_Parity_Diff'] = max(pprs) - min(pprs)
    
    return results

# ตัวอย่างการใช้งาน
# metrics = calculate_fairness_metrics(y_true, y_pred, gender)
# print(f"ความแตกต่าง Demographic Parity: {metrics['Demographic_Parity_Diff']:.4f}")

1.6.3 ความโปร่งใสและอธิบายได้ (Transparency and Explainability)

Explainable AI (XAI) คือ แนวทางการพัฒนา AI ที่ทำให้ผู้ใช้สามารถ เข้าใจและตรวจสอบ การตัดสินใจของระบบได้

ปัญหา Black Box:

เทคนิค XAI ที่นิยม:

1.6.4 ผลกระทบต่อสังคมและเศรษฐกิจ

ด้าน ผลกระทบเชิงบวก ผลกระทบเชิงลบ
การจ้างงาน สร้างอาชีพใหม่ งานบางประเภทถูกแทนที่
การศึกษา Personalized Learning ความเหลื่อมล้ำในการเข้าถึง
สุขภาพ การวินิจฉัยแม่นยำขึ้น ความเป็นส่วนตัวของข้อมูล
ความปลอดภัย ตรวจจับภัยคุกคาม การใช้ในทางที่ผิด
สิ่งแวดล้อม เพิ่มประสิทธิภาพพลังงาน การใช้พลังงานในการฝึก AI

1.6.5 หลักการจริยธรรม AI

หลักการที่องค์กรต่างๆ เสนอสำหรับการพัฒนา AI อย่างมีจริยธรรม:

  1. ความเป็นธรรม (Fairness) - ไม่เลือกปฏิบัติ
  2. ความโปร่งใส (Transparency) - อธิบายได้
  3. ความเป็นส่วนตัว (Privacy) - ปกป้องข้อมูล
  4. ความปลอดภัย (Safety) - ไม่ก่อให้เกิดอันตราย
  5. ความรับผิดชอบ (Accountability) - มีผู้รับผิดชอบ
  6. ความทนทาน (Robustness) - ทำงานได้อย่างน่าเชื่อถือ
  7. การควบคุมโดยมนุษย์ (Human Oversight) - มนุษย์ยังเป็นผู้ตัดสินใจ

1.7 เครื่องมือและการเตรียมความพร้อม (Tools and Environment Setup)

1.7.1 Python Environment Setup

Anaconda เป็น Distribution ที่รวมเครื่องมือสำหรับ Data Science และ AI ไว้ครบถ้วน

"""
ขั้นตอนการติดตั้งและตั้งค่าสภาพแวดล้อม Python สำหรับ AI
"""

# 1. สร้าง Conda Environment สำหรับโปรเจค AI
# conda create -n ai_course python=3.11

# 2. เปิดใช้งาน Environment
# conda activate ai_course

# 3. ติดตั้ง Libraries พื้นฐาน
# pip install numpy pandas matplotlib seaborn

# 4. ติดตั้ง Machine Learning Libraries
# pip install scikit-learn

# 5. ติดตั้ง Deep Learning Frameworks
# pip install tensorflow torch torchvision

# 6. ติดตั้ง Jupyter Notebook
# pip install jupyter notebook

# 7. ตรวจสอบการติดตั้ง
import sys
print(f"Python Version: {sys.version}")

try:
    import numpy as np
    import pandas as pd
    import sklearn
    print(f"NumPy: {np.__version__}")
    print(f"Pandas: {pd.__version__}")
    print(f"Scikit-learn: {sklearn.__version__}")
except ImportError as e:
    print(f"ไม่พบ Library: {e}")

1.7.2 Google Colab

Google Colab เป็นบริการ Jupyter Notebook บนคลาวด์ที่ให้บริการ GPU และ TPU ฟรี

ข้อดีของ Google Colab:

"""
ตัวอย่างการใช้งาน Google Colab
"""

# ตรวจสอบ GPU ที่มีใน Colab
# !nvidia-smi

# เชื่อมต่อกับ Google Drive
from google.colab import drive
drive.mount('/content/drive')

# ติดตั้ง Library เพิ่มเติม
# !pip install transformers

# อัปโหลดไฟล์
from google.colab import files
# uploaded = files.upload()

# ดาวน์โหลดไฟล์
# files.download('model.h5')

1.7.3 Git & GitHub

Git เป็นระบบ Version Control สำหรับจัดการ Source Code และ GitHub เป็นแพลตฟอร์มสำหรับเก็บ Repository

# คำสั่ง Git พื้นฐาน

# ตั้งค่า Git
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

# สร้าง Repository ใหม่
git init

# Clone Repository
git clone https://github.com/username/repo.git

# ตรวจสอบสถานะ
git status

# เพิ่มไฟล์
git add .

# Commit
git commit -m "เพิ่มโมเดล AI สำหรับ classification"

# Push ขึ้น Remote
git push origin main

# Pull ข้อมูลล่าสุด
git pull origin main

# สร้าง Branch ใหม่
git checkout -b feature/new-model

1.7.4 Visual Studio Code

VS Code เป็น IDE ที่นิยมสำหรับการพัฒนา AI/ML เนื่องจากมี Extensions ที่มีประโยชน์

Extensions แนะนำสำหรับ AI Development:


1.8 สรุปโดยรวม (Summary)

1.8.1 ประเด็นสำคัญที่ได้เรียนรู้

flowchart TB
    subgraph Summary["สรุปบทเรียน: บทนำสู่ปัญญาประดิษฐ์"]
        A["นิยาม AI
ระบบที่แสดงพฤติกรรมอัจฉริยะ"] B["ประวัติ AI
1943 - ปัจจุบัน"] C["สาขาของ AI
ML, CV, NLP, Robotics"] D["ประเภท AI
Narrow vs General vs Super"] E["Intelligent Agents
Perceive → Decide → Act"] F["จริยธรรม AI
Fairness, Transparency, Safety"] G["เครื่องมือ
Python, Colab, Git, VS Code"] end A --> B --> C --> D --> E --> F --> G style A fill:#458588,stroke:#282828,color:#ebdbb2 style B fill:#98971a,stroke:#282828,color:#282828 style C fill:#d79921,stroke:#282828,color:#282828 style D fill:#cc241d,stroke:#282828,color:#ebdbb2 style E fill:#b16286,stroke:#282828,color:#ebdbb2 style F fill:#689d6a,stroke:#282828,color:#282828 style G fill:#fe8019,stroke:#282828,color:#282828

1.8.2 ทักษะพื้นฐานที่ควรมี

สำหรับการศึกษา AI อย่างมีประสิทธิภาพ นักศึกษาควรมีพื้นฐานดังนี้:

  1. คณิตศาสตร์

  2. การเขียนโปรแกรม

  3. ความคิดเชิงวิเคราะห์


1.9 เอกสารอ้างอิง (References)

หนังสือหลัก

  1. Russell, S., & Norvig, P. (2021). Artificial Intelligence: A Modern Approach (4th ed.). Pearson.

  2. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.

  3. Mitchell, T. M. (1997). Machine Learning. McGraw-Hill.

แหล่งเรียนรู้ออนไลน์

เอกสารเชิงจริยธรรม