SlideShare a Scribd company logo
1 of 8
Download to read offline
モデル
予測値Y’ 真の予測値Y
損失関数
損失率
オプティマイザー
①モデルは何か?
②損失関数は何を使っているか?
③オプティマイザーは何を使っているか?
15num_coeffs = 6
16trY_coeffs = [1, 2, 3, 4, 5, 6]
17trY = 0
18for i in range(num_coeffs):
19 #print(i)
20 trY += trY_coeffs[i] * np.power(trX, i)
21 #print(trX)
22 #print(trY)
23
24trY += np.random.randn(*trX.shape) * 1.5
25
26#print(trX)
27#print(trY)
28plt.scatter(trX, trY)
29plt.show()
F(x) = Wn*X^n + … + W1*x + W0
https://github.com/RuoAndo/seminar/blob/master/jt/7-nonlinear.py
41w = tf.Variable([0.] * num_coeffs, name="parameters")
42y_model = model(X, w)
43
44cost = tf.reduce_sum(tf.square(Y-y_model))
45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
46
47sess = tf.Session()
48init = tf.global_variables_initializer()
49sess.run(init)
50
51for epoch in range(training_epochs):
52 for (x, y) in zip(trX, trY):
53 sess.run(train_op, feed_dict={X: x, Y: y})
54
55w_val = sess.run(w)
56print(w_val)
[1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995]
session.runの引数
train_opを探す。
41w = tf.Variable([0.] * num_coeffs, name="parameters")
42y_model = model(X, w)
43
44cost = tf.reduce_sum(tf.square(Y-y_model))
45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
46
47sess = tf.Session()
48init = tf.global_variables_initializer()
49sess.run(init)
50
51for epoch in range(training_epochs):
52 for (x, y) in zip(trX, trY):
53 sess.run(train_op, feed_dict={X: x, Y: y})
54
55w_val = sess.run(w)
56print(w_val)
[1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995]
損失関数は
何か?
41w = tf.Variable([0.] * num_coeffs, name="parameters")
42y_model = model(X, w)
43
44cost = tf.reduce_sum(tf.square(Y-y_model))
45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
46
47sess = tf.Session()
48init = tf.global_variables_initializer()
49sess.run(init)
50
51for epoch in range(training_epochs):
52 for (x, y) in zip(trX, trY):
53 sess.run(train_op, feed_dict={X: x, Y: y})
54
55w_val = sess.run(w)
56print(w_val)
[1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995]
モデルを探す。
41w = tf.Variable([0.] * num_coeffs, name="parameters")
42y_model = model(X, w)
43
44cost = tf.reduce_sum(tf.square(Y-y_model))
45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
46
47sess = tf.Session()
48init = tf.global_variables_initializer()
49sess.run(init)
50
51for epoch in range(training_epochs):
52 for (x, y) in zip(trX, trY):
53 sess.run(train_op, feed_dict={X: x, Y: y})
54
55w_val = sess.run(w)
56print(w_val)
[1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995]
34def model(X, w):
35 terms = []
36 for i in range(num_coeffs):
37 term = tf.multiply(w[i], tf.pow(X, i))
38 terms.append(term)
39 return tf.add_n(terms)
モデル
34def model(X, w):
35 terms = []
36 for i in range(num_coeffs):
37 term = tf.multiply(w[i], tf.pow(X, i))
38 terms.append(term)
39 return tf.add_n(terms)
モデル
15num_coeffs = 6
16trY_coeffs = [1, 2, 3, 4, 5, 6]
17trY = 0
18for i in range(num_coeffs):
19 #print(i)
20 trY += trY_coeffs[i] * np.power(trX, i)
生成器
60plt.scatter(trX, trY)
61trY2 = 0
62for i in range(num_coeffs):
63 trY2 += w_val[i] * np.power(trX, i)
64plt.plot(trX, trY2, 'r')
65plt.show()
15num_coeffs = 6
16trY_coeffs = [1, 2, 3, 4, 5, 6]
17trY = 0
18for i in range(num_coeffs):
19 #print(i)
20 trY += trY_coeffs[i] * np.power(trX, i)
生成器

More Related Content

What's hot

Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Robert John
 
What is TensorFlow and why do we use it
What is TensorFlow and why do we use itWhat is TensorFlow and why do we use it
What is TensorFlow and why do we use itRobert John
 
Extreme Value
Extreme ValueExtreme Value
Extreme Valuenclamelas
 
Public class arithmetic operatordemo
Public class arithmetic operatordemoPublic class arithmetic operatordemo
Public class arithmetic operatordemoCliff Rodrigo
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest DescentJeremy Lane
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
Sketching derivatives
Sketching derivativesSketching derivatives
Sketching derivativesssuserdb91c91
 
Rombo matriz
Rombo matrizRombo matriz
Rombo matrizepetekaun
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab CompletoRicardo Grandas
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4Vanishree Arun
 
Derivatives in graphing-dfs
Derivatives in graphing-dfsDerivatives in graphing-dfs
Derivatives in graphing-dfsFarhana Shaheen
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Languagelijx127
 

What's hot (20)

Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019
 
What is TensorFlow and why do we use it
What is TensorFlow and why do we use itWhat is TensorFlow and why do we use it
What is TensorFlow and why do we use it
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
Extreme Value
Extreme ValueExtreme Value
Extreme Value
 
Public class arithmetic operatordemo
Public class arithmetic operatordemoPublic class arithmetic operatordemo
Public class arithmetic operatordemo
 
Segundo Punto
Segundo PuntoSegundo Punto
Segundo Punto
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest Descent
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Sketching derivatives
Sketching derivativesSketching derivatives
Sketching derivatives
 
week-15x
week-15xweek-15x
week-15x
 
Rombo matriz
Rombo matrizRombo matriz
Rombo matriz
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab Completo
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4
 
Pointer example
Pointer examplePointer example
Pointer example
 
Taller De Scilab
Taller De ScilabTaller De Scilab
Taller De Scilab
 
Trabajo Scilab
Trabajo ScilabTrabajo Scilab
Trabajo Scilab
 
Derivatives in graphing-dfs
Derivatives in graphing-dfsDerivatives in graphing-dfs
Derivatives in graphing-dfs
 
Quad fcn
Quad fcnQuad fcn
Quad fcn
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 
Proga 0601
Proga 0601Proga 0601
Proga 0601
 

Similar to 【AI実装4】TensorFlowのプログラムを読む2 非線形回帰

Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12OdessaFrontend
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxlauracallander
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPaulo Sergio Lemes Queiroz
 
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...ETS Asset Management Factory
 
Succumbing to the Python in Financial Markets
Succumbing to the Python in Financial MarketsSuccumbing to the Python in Financial Markets
Succumbing to the Python in Financial Marketsdcerezo
 
Pytorch for tf_developers
Pytorch for tf_developersPytorch for tf_developers
Pytorch for tf_developersAbdul Muneer
 
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTaegyun Jeon
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to TensorflowTzar Umang
 
Regression Tree.pdf
Regression Tree.pdfRegression Tree.pdf
Regression Tree.pdfIvanHartana4
 
Assignment 6.2a.pdf
Assignment 6.2a.pdfAssignment 6.2a.pdf
Assignment 6.2a.pdfdash41
 
Python profiling
Python profilingPython profiling
Python profilingdreampuf
 
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...Databricks
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3Max Kleiner
 
Intelligent System Optimizations
Intelligent System OptimizationsIntelligent System Optimizations
Intelligent System OptimizationsMartin Zapletal
 

Similar to 【AI実装4】TensorFlowのプログラムを読む2 非線形回帰 (20)

Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
 
Succumbing to the Python in Financial Markets
Succumbing to the Python in Financial MarketsSuccumbing to the Python in Financial Markets
Succumbing to the Python in Financial Markets
 
Pytorch for tf_developers
Pytorch for tf_developersPytorch for tf_developers
Pytorch for tf_developers
 
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to Tensorflow
 
Regression Tree.pdf
Regression Tree.pdfRegression Tree.pdf
Regression Tree.pdf
 
Assignment 6.2a.pdf
Assignment 6.2a.pdfAssignment 6.2a.pdf
Assignment 6.2a.pdf
 
Python profiling
Python profilingPython profiling
Python profiling
 
Os lab upto_1st_mid
Os lab upto_1st_midOs lab upto_1st_mid
Os lab upto_1st_mid
 
Os lab upto 1st mid
Os lab upto 1st midOs lab upto 1st mid
Os lab upto 1st mid
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
Intelligent System Optimizations
Intelligent System OptimizationsIntelligent System Optimizations
Intelligent System Optimizations
 
Python
PythonPython
Python
 

More from Ruo Ando

KISTI-NII Joint Security Workshop 2023.pdf
KISTI-NII Joint Security Workshop 2023.pdfKISTI-NII Joint Security Workshop 2023.pdf
KISTI-NII Joint Security Workshop 2023.pdfRuo Ando
 
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤Ruo Ando
 
解説#86 決定木 - ss.pdf
解説#86 決定木 - ss.pdf解説#86 決定木 - ss.pdf
解説#86 決定木 - ss.pdfRuo Ando
 
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座  ~アイドル戦略に見るDXを専門家が徹底解説~SaaSアカデミー for バックオフィス アイドルと学ぶDX講座  ~アイドル戦略に見るDXを専門家が徹底解説~
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~Ruo Ando
 
解説#83 情報エントロピー
解説#83 情報エントロピー解説#83 情報エントロピー
解説#83 情報エントロピーRuo Ando
 
解説#82 記号論理学
解説#82 記号論理学解説#82 記号論理学
解説#82 記号論理学Ruo Ando
 
解説#81 ロジスティック回帰
解説#81 ロジスティック回帰解説#81 ロジスティック回帰
解説#81 ロジスティック回帰Ruo Ando
 
解説#74 連結リスト
解説#74 連結リスト解説#74 連結リスト
解説#74 連結リストRuo Ando
 
解説#76 福岡正信
解説#76 福岡正信解説#76 福岡正信
解説#76 福岡正信Ruo Ando
 
解説#77 非加算無限
解説#77 非加算無限解説#77 非加算無限
解説#77 非加算無限Ruo Ando
 
解説#1 C言語ポインタとアドレス
解説#1 C言語ポインタとアドレス解説#1 C言語ポインタとアドレス
解説#1 C言語ポインタとアドレスRuo Ando
 
解説#78 誤差逆伝播
解説#78 誤差逆伝播解説#78 誤差逆伝播
解説#78 誤差逆伝播Ruo Ando
 
解説#73 ハフマン符号
解説#73 ハフマン符号解説#73 ハフマン符号
解説#73 ハフマン符号Ruo Ando
 
【技術解説20】 ミニバッチ確率的勾配降下法
【技術解説20】 ミニバッチ確率的勾配降下法【技術解説20】 ミニバッチ確率的勾配降下法
【技術解説20】 ミニバッチ確率的勾配降下法Ruo Ando
 
【技術解説4】assertion failureとuse after-free
【技術解説4】assertion failureとuse after-free【技術解説4】assertion failureとuse after-free
【技術解説4】assertion failureとuse after-freeRuo Ando
 
ITmedia Security Week 2021 講演資料
ITmedia Security Week 2021 講演資料 ITmedia Security Week 2021 講演資料
ITmedia Security Week 2021 講演資料 Ruo Ando
 
ファジングの解説
ファジングの解説ファジングの解説
ファジングの解説Ruo Ando
 
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月Ruo Ando
 
Intel Trusted Computing Group 1st Workshop
Intel Trusted Computing Group 1st WorkshopIntel Trusted Computing Group 1st Workshop
Intel Trusted Computing Group 1st WorkshopRuo Ando
 
情報セキュリティと標準化I 第15回
情報セキュリティと標準化I 第15回情報セキュリティと標準化I 第15回
情報セキュリティと標準化I 第15回Ruo Ando
 

More from Ruo Ando (20)

KISTI-NII Joint Security Workshop 2023.pdf
KISTI-NII Joint Security Workshop 2023.pdfKISTI-NII Joint Security Workshop 2023.pdf
KISTI-NII Joint Security Workshop 2023.pdf
 
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
 
解説#86 決定木 - ss.pdf
解説#86 決定木 - ss.pdf解説#86 決定木 - ss.pdf
解説#86 決定木 - ss.pdf
 
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座  ~アイドル戦略に見るDXを専門家が徹底解説~SaaSアカデミー for バックオフィス アイドルと学ぶDX講座  ~アイドル戦略に見るDXを専門家が徹底解説~
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~
 
解説#83 情報エントロピー
解説#83 情報エントロピー解説#83 情報エントロピー
解説#83 情報エントロピー
 
解説#82 記号論理学
解説#82 記号論理学解説#82 記号論理学
解説#82 記号論理学
 
解説#81 ロジスティック回帰
解説#81 ロジスティック回帰解説#81 ロジスティック回帰
解説#81 ロジスティック回帰
 
解説#74 連結リスト
解説#74 連結リスト解説#74 連結リスト
解説#74 連結リスト
 
解説#76 福岡正信
解説#76 福岡正信解説#76 福岡正信
解説#76 福岡正信
 
解説#77 非加算無限
解説#77 非加算無限解説#77 非加算無限
解説#77 非加算無限
 
解説#1 C言語ポインタとアドレス
解説#1 C言語ポインタとアドレス解説#1 C言語ポインタとアドレス
解説#1 C言語ポインタとアドレス
 
解説#78 誤差逆伝播
解説#78 誤差逆伝播解説#78 誤差逆伝播
解説#78 誤差逆伝播
 
解説#73 ハフマン符号
解説#73 ハフマン符号解説#73 ハフマン符号
解説#73 ハフマン符号
 
【技術解説20】 ミニバッチ確率的勾配降下法
【技術解説20】 ミニバッチ確率的勾配降下法【技術解説20】 ミニバッチ確率的勾配降下法
【技術解説20】 ミニバッチ確率的勾配降下法
 
【技術解説4】assertion failureとuse after-free
【技術解説4】assertion failureとuse after-free【技術解説4】assertion failureとuse after-free
【技術解説4】assertion failureとuse after-free
 
ITmedia Security Week 2021 講演資料
ITmedia Security Week 2021 講演資料 ITmedia Security Week 2021 講演資料
ITmedia Security Week 2021 講演資料
 
ファジングの解説
ファジングの解説ファジングの解説
ファジングの解説
 
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
 
Intel Trusted Computing Group 1st Workshop
Intel Trusted Computing Group 1st WorkshopIntel Trusted Computing Group 1st Workshop
Intel Trusted Computing Group 1st Workshop
 
情報セキュリティと標準化I 第15回
情報セキュリティと標準化I 第15回情報セキュリティと標準化I 第15回
情報セキュリティと標準化I 第15回
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

【AI実装4】TensorFlowのプログラムを読む2 非線形回帰

  • 2. 15num_coeffs = 6 16trY_coeffs = [1, 2, 3, 4, 5, 6] 17trY = 0 18for i in range(num_coeffs): 19 #print(i) 20 trY += trY_coeffs[i] * np.power(trX, i) 21 #print(trX) 22 #print(trY) 23 24trY += np.random.randn(*trX.shape) * 1.5 25 26#print(trX) 27#print(trY) 28plt.scatter(trX, trY) 29plt.show() F(x) = Wn*X^n + … + W1*x + W0 https://github.com/RuoAndo/seminar/blob/master/jt/7-nonlinear.py
  • 3. 41w = tf.Variable([0.] * num_coeffs, name="parameters") 42y_model = model(X, w) 43 44cost = tf.reduce_sum(tf.square(Y-y_model)) 45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) 46 47sess = tf.Session() 48init = tf.global_variables_initializer() 49sess.run(init) 50 51for epoch in range(training_epochs): 52 for (x, y) in zip(trX, trY): 53 sess.run(train_op, feed_dict={X: x, Y: y}) 54 55w_val = sess.run(w) 56print(w_val) [1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995] session.runの引数 train_opを探す。
  • 4. 41w = tf.Variable([0.] * num_coeffs, name="parameters") 42y_model = model(X, w) 43 44cost = tf.reduce_sum(tf.square(Y-y_model)) 45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) 46 47sess = tf.Session() 48init = tf.global_variables_initializer() 49sess.run(init) 50 51for epoch in range(training_epochs): 52 for (x, y) in zip(trX, trY): 53 sess.run(train_op, feed_dict={X: x, Y: y}) 54 55w_val = sess.run(w) 56print(w_val) [1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995] 損失関数は 何か?
  • 5. 41w = tf.Variable([0.] * num_coeffs, name="parameters") 42y_model = model(X, w) 43 44cost = tf.reduce_sum(tf.square(Y-y_model)) 45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) 46 47sess = tf.Session() 48init = tf.global_variables_initializer() 49sess.run(init) 50 51for epoch in range(training_epochs): 52 for (x, y) in zip(trX, trY): 53 sess.run(train_op, feed_dict={X: x, Y: y}) 54 55w_val = sess.run(w) 56print(w_val) [1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995] モデルを探す。
  • 6. 41w = tf.Variable([0.] * num_coeffs, name="parameters") 42y_model = model(X, w) 43 44cost = tf.reduce_sum(tf.square(Y-y_model)) 45train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) 46 47sess = tf.Session() 48init = tf.global_variables_initializer() 49sess.run(init) 50 51for epoch in range(training_epochs): 52 for (x, y) in zip(trX, trY): 53 sess.run(train_op, feed_dict={X: x, Y: y}) 54 55w_val = sess.run(w) 56print(w_val) [1.0518903 1.7557341 4.2570124 5.756541 3.2840345 5.1628995] 34def model(X, w): 35 terms = [] 36 for i in range(num_coeffs): 37 term = tf.multiply(w[i], tf.pow(X, i)) 38 terms.append(term) 39 return tf.add_n(terms) モデル
  • 7. 34def model(X, w): 35 terms = [] 36 for i in range(num_coeffs): 37 term = tf.multiply(w[i], tf.pow(X, i)) 38 terms.append(term) 39 return tf.add_n(terms) モデル 15num_coeffs = 6 16trY_coeffs = [1, 2, 3, 4, 5, 6] 17trY = 0 18for i in range(num_coeffs): 19 #print(i) 20 trY += trY_coeffs[i] * np.power(trX, i) 生成器
  • 8. 60plt.scatter(trX, trY) 61trY2 = 0 62for i in range(num_coeffs): 63 trY2 += w_val[i] * np.power(trX, i) 64plt.plot(trX, trY2, 'r') 65plt.show() 15num_coeffs = 6 16trY_coeffs = [1, 2, 3, 4, 5, 6] 17trY = 0 18for i in range(num_coeffs): 19 #print(i) 20 trY += trY_coeffs[i] * np.power(trX, i) 生成器