---
# System prepended metadata

title: AI Ch.01
tags: [110-2, NTNU, CSIE, 選修, AI]

---

---
title: AI Ch.01
---
# Artificial Intelligence
NTNU 人工智慧
##### [Back to Note Overview](https://reurl.cc/XXeYaE)
##### [Back to Artificial Intelligence](https://hackmd.io/@NTNUCSIE112/AI110-2)
{%hackmd @sophie8909/pink_theme %}
###### tags: `AI` `110-2` `CSIE` `選修` `NTNU`
<!-- tag順序 [學校] [系 必選]  or  [學程 學程名(不含學程的 e.g. 大師創業)] [課程] [開課學期]-->
<!-- 網址名稱 SP110-1_[] -->

## Ch.0
### 什麼是智慧？
> Intelligence: The ability to learn and solve problems [name=Webster's Dictionary]
- "Philosophia"：愛好智慧
- 1985 年美國心理學家 Sternberg 提出智慧三元論。
    - Emphasizes how 3 types of abilities work together to create intelligent behavior
        - Triarchic Theory
            - Analytical
                - compare, evaluate and analyze
            - Creative
                - insights, synthesis, adapting in unique situations
            - Practical
                - dealing with everyday tasks relating to world
### AI 是否會主宰人類世界
> 我們很有必要給人工智慧加上一個「紅色按鈕」，用來阻止其傷害人類和環境...，但人翁智慧也有可能學會防止自己被人類關機...[name=Deepmind和牛津大學]
> 人工智慧終究會帶來人類的末日 [name=霍金]
> AI 是人類生存最大的威脅！AI 可能比核武器更危險[name=特斯拉創辦人馬斯克]
### AI 的兩個重要里程碑
- 1997年：IMB 深藍（Deep Blue）擊敗西洋棋棋王 Kasparov
- 2016年：Google Deepmind's AlphaGp 擊敗李世石（Lee Sedol）
    - 2017 3 場完勝柯潔

### 強弱 AI
- 弱人工智慧：認為**不可能**製造出能真正地推理和解決問題的智能機器，只是看起來像是智能的但不是真正擁有智能，也不會有自主意識
- 強人工智慧：認為**有可能**製造出能真正地推理和解決問題的智能機器，這樣的機器被認為是有知覺和有自我意識的。強人工智慧有分兩種
    - 類人的人工智慧：機器的思考和推理就像人的思維一樣
    - 非類人的人工智慧：機器產生了和人完全不一樣的知覺和意識，使用和人完全不一樣的推理方式
## Ch.01 Introduction





### 1.1 What is AI?
#### AI 定義
- Systems that ...

    |                   | fidelity 保真性   | rationality 理性 |
    | -----------------: | :-----------------: | :----------------: |
    | thought/reasoning | think like humans | think rationally |
    | behavior          | act like humans   | act rationally                 |
- Acting humanly
    - Turing test
    	- The test is for a program to have a conversation via online typed messages with an interrogator who has to guess if the conversation is with a machine or a person
    	- The program passes the test if it fools the interrogator（審訊者）
    	- Total Turing Test
    	    - require interaction with objects and people in real world
- Acting rationally
    - Rational Agent
        - just something that perceives and acts
        - autonomously, adaptively, goal-directly
    - do the right thing
        - expected to maximize the goal achievement, given the available information
        - **don't necessarily** involve think/inference
    - e.g. car factory
- Thinking Humanly
    - cognitive modeling 認知模型
        - 對人（或動物）認知過程的近似
    - require 
        - to **know how** people think
        - scientific theories of internal activities of the brain
    - once have a sufficiency precise theory of human mind, we can express it as a computer program
- Thinking Rationally
    - Laws of thought
    - correct inference
        - correct premises yield correct conclusions
    - formal logic
        - define a **precise notion** for statements about all things and the relations among them
        - main considerations
            - not all things can be represented in logic forms
            - computation complexity is high
    - example: 四色定理、布林畢氏三元數問題、證明 n = 7825 不能成功著色
### 1.2 Foundations of AI 
- Philosophy 哲學 (428 B.C. - present)
    - **logic, methods of reasoning**
    - Aristotle（亞里斯多德）：A set of rules that can describe the formal/rational part of mid. 
    - Mind as a physical system/computation process
    - Knowledge acquired from experiences and encoded in mind, and used to choose right actions.
    - Learning, language, rationality
- Mathematics 數學 (800 - present)
	-** Formal representation and proof**
		- Tools to manipulate logical/probabilistic statements
		- Groundwork for computation and algorithms
    - Three main contributions:
	    - logic, computation, and probability
- Economics 經濟學 (1776 - present)
    - Formal theory for making decisions
	- Utility: the preferred outcomes
	- Decision theory
	- Game theory
	- Operations research
- Neuroscience 神經科學 (1861 - present)
	- Brain cause minds: The mapping between areas of the brain and the parts of body they control or from which they receive sensory input
	- Ramon y Cajal（拉蒙卡哈）：神經解剖學者、1906 諾貝爾獎得主
	    - 提出新學說：腦神經是由個別的神經元組成，在神經內訊號以單一方向傳遞訊號（樹突→細胞核→軸突→突觸）。
	        - 人腦約有 500-1000億個（$10^{11}$）神經元，速度 $10^{-3}$ sec
	        - 矽晶片 $10^9$ sec
- Psychology 物理學 (1879 - present)
    - Brains as information-processing devices
    - Knowledge-based agent
        - Stimulus（刺激） translated into an internal representation
        - Cognitive process derive new representation from it
        - These representations are in turn retranslated into action
- Computer engineering 計算機工程 (1940 - present)
	- Artifacts for implementing AI ideas
		- (Software) programming languages
		- The increase in speed and memory
- Control theory 控制理論 (1948 - present)
	- Design simple optimal agents receiving feedback from the environment
		- Maximizing an objective function over time
		- Minimize the difference between current and goal states
- Linguistics 語言學 (1957 - present)
    - How does language relate to thought?
	- Languages fit information processing model
	- Understanding languages requires an understanding of subject matter and context
### 1.3 History of AI
- 1943-55  Gestation（孕育） of AI
    - McCulloch & Pitt : Boolean circut model of neurons
    - Turing's "Computing Machinery and Intelligence"
- **1956 The birth of AI**
    - Darthmouth meeting: "Artificial Intelligence" adopted
- 1966 ELIZA: a simple natural-language understanding program
- 1966-85 Neural Network almost disappear
    - No efficient training algorithm for layered networks
- 1969-79 Knowledge-based systems
    - 1968 MIT Microworlds: "(geometric) analogy problem"
    - 1972 MIT Microworlds: "blocks world" SHRDLU, rearrange the blocks in a certain way
- 1980-88 Expert system industry booms 
    - a million dollars to billion of dollars
    - 1981 Japanese's 5th generation Computer running Prolog
- 1986- Neural networks return to popularity
- 1988-93 Expert system busts："AI winter"
- 1996 IBM Deep Blue 打輸世界西洋棋棋王 2-4
- 1997 IBM Deep Blue 打敗世界西洋棋棋王 **Garry Kasparov** 3.5-2.5
- 2006- Marvin Minsky: The Emotion Machine
- 2001-present Large datasets. Data will drive future discoveries and alleviate the complexity in AI
    - 2001 Banko and Brill, word-sense disambiguation（歧義解釋）
    - 2007 Hays and Efros , filling in holes in a photograph
- 2010-present Machine learning is everywhere
- 2016 03, `AlphaGo` defeated the Go﹙圍棋﹚ champion **Lee Sedol**, a 9 dan profession, 4-1.

### 講義填空
- Ch1-21 `AlphaGo`
- 

### Ch1後 實作類神降算神秘函數

#### Code
:arrow_right: [repl.it](https://replit.com/languages/python3)

:::spoiler sample code
```python=
#講義第六頁 sample code
from numpy import *
train_in = array([[0,2,0],[0,0,1],[0,1,1],[1,0,1],[1,1,1]])
train_sol = array([[0,0,0,1,1]]).T

# Initialize nn_weights
random.seed(1)
nn_weights = 2 * random.random((3, 1)) - 1

# Train the network
for i in range(200):
    print("\n i= ", i, "nn_weight=")
    print(nn_weights)
    
    # Calculate the outputs for each training examples
    train_out = 1 / (1 + exp(-(dot(train_in, nn_weights))))
    print("train_out =")
    print(train_out)
    
    # Run the NN adjustments
    nn_weights += dot(train_in.T, (train_sol-train_out)*train_out*(1-train_out))
    
# Unknown test input
test_in = array([1,0,0])
# Print the result for our unknown test input
print('\nThe final prediction is ',1/(1 + exp(-(dot(test_in, nn_weights)))))
```
:::

#### 神經元
![](https://i.imgur.com/voGPIKG.png)

cell body
sigma wixi+b

<!-- 不知道哪裡的
神經元
權重
激勵函數
 -->

