Kerasã§è¤æ°ã®æ å ±ãå ¥åãã¦ãéä¸ã§çµåããæ¹æ³ãç´¹ä»ãã¾ãã ãã®æ¹æ³ã¯ãä¾ãã°ä»¥ä¸ã®ããã«ç»åã¨ããã¹ãã使ã£ã¦äºæ¸¬ã¢ãã«ãä½ãå ´åãªã©ã«æå¹ã§ãããªã³ã¯å åèã ImageDataGeneratorã使ãã¤ã¤çµ±åããæ¹æ³ã¯ãè¨äºãKerasã®ImageDataGeneratorã使ãã¤ã¤è¤æ°Inputçµ±åã¢ãã«ããåç §ãã ããã å¦çæ¦è¦ 以åãè¨äºããKeraså ¥é(1)ãåç´ãªãã£ã¼ãã©ã¼ãã³ã°ã¢ãã«å®ç¾©ãã§ç´¹ä»ãã以ä¸ã®å³ã®é ådataã2ã¤ã«å解ãã¦çµ±åããã¢ãã«ã«ãã¦ã¿ã¾ãã å¦çããã°ã©ã ããã°ã©ã å ¨ä½ã¯GitHubãåç §ãã ããã â»ãªããç´æ¥GitHubã§è¦ãããã«ãnbviewerãªãåç §ã§ãã¾ãããnbviewerã«https://github.com/YoheiFukuhara/keras-for-beginner/blob/master/Keras09_
ã¯ããã« ã«ãã¯ã§æ©æ¢°å¦ç¿ã¨ã³ã¸ãã¢ããã¦ãã大串æ£ç¢ã§ããä»åã¯è¤æ°æç³»åãã¼ã¿ã1ã¤ã®æ·±å±¤å¦ç¿ã¢ãã«ã§å¦ç¿ãããæ¹æ³ã«ã¤ãã¦æ¸ãã¾ãã èæ¯ è¤æ°æç³»åãã¼ã¿ã¯è¤æ°ä¼æ¥ã®æ ªä¾¡ã®å¤åãåå°åã«ãããæ°æ¸©å¤åãè¤æ°ãã·ã¼ã³ã®ãã°ãªã©å¤å²ã«æ¸¡ã£ã¦è¦³æ¸¬ã§ãã¾ãããã®æç³»åãã¨ã«ã¢ãã«ãç¨æãã¦ç®¡çããã¨ãªãã¨å¦ç¿ãéç¨ã«ããã¦å¤å¤§ãªãã³ã¹ããããã£ã¦ãã¾ãã¾ãã1ã¤ã®ã¢ãã«ã§è¤æ°ã®æç³»åã管çã§ããã°éç¨ã楽ã«ãªãã ãã§ãªããå¦ç¿ã1度ã§æ¸ãã®ã§ãã©ã¤ã¢ã³ãã¨ã©ã¼ã®å·¥æ°ãå¤§å¹ ã«åæ¸ã§ãã¾ãã æ¬è¨äºã§ã¯ãã®ããã«å®ç¾å¯è½ãª2ã¤ã®ææ³ãç´¹ä»ãã¾ãã Kerasã§è¤æ°ã®æç³»åãã¼ã¿ã深層å¦ç¿ã¢ãã«ã§å¦ç¿ãããææ³ã«ã¯2ã¤ããã¾ãã è¤æ°å ¥ååã®æ·±å±¤å¦ç¿ã¢ãã« åå¥å ¥ååã®æ·±å±¤å¦ç¿ã¢ãã«ã®çµã¿åãã 1ã®ææ³ã®å©ç¹ã¯ã¢ãã«ãã·ã³ãã«ãªã®ã§å¦ç¿ã¨äºæ¸¬ã2ã®ææ³ã«æ¯ã¹é«éã«ãªãã¾ãã 2ã®ææ³ã®å©ç¹ã¯æ
åå¤éã®æç³»åã¯kerasã§ãããè¦ãã®ã§ãããæ ªä¾¡ã売ä¸ãªã©ãäºæ¸¬ããæãªã©ã«ã¯è¤æ°ã®è¦å ãé¢ãã£ã¦ãã¾ãã®ã§ãä»åã¯è¤æ°ã®æç³»åãã¼ã¿ã使ã£ã¦äºæ¸¬ãã¦ã¿ã¾ããã ã½ã¼ã¹ã®ç´¹ä» ã³ã¼ã ãMACHINE LEARNING MASTERYãã§ç´¹ä»ããã¦ããã³ã¼ããåºæ¬ã«ãå¤å¤é対å¿ã«ãã¾ããã Time Series Prediction with LSTM Recurrent Neural Networks in Python with Keras jupyterã§è¦ããã³ã¼ãã®å ¨è²ã¯ãã¡ã https://github.com/tizuo/keras/blob/master/LSTM%20with%20multi%20variables.ipynb ãã¼ã¿ ãµã³ãã«ãã¼ã¿ã¯ä»¥ä¸ããæåãã¾ãããä¸çªå·¦ã®ice_salesãäºæ¸¬ãã¾ãã ã¢ã¤ã¹ã¯ãªã¼ã ã®å£²ãæ¹ ice_sales yea
æç³»åãã¼ã¿è§£æã®çºã«RNNã使ã£ã¦ã¿ããã¨æãï¼ç°¡åãªå®è£ ããã¦,æç³»åãã¼ã¿ã¨ã㦠ã»ã¨ãã©ï¼ä»¥ä¸ã®çä¼¼ãã¨ãªã®ã§ãããã¯ãã¡ãã«ãé¡ããã¾ãï¼ æ·±å±¤å¦ç¿ã©ã¤ãã©ãªKerasã§RNNã使ã£ã¦sinæ³¢äºæ¸¬ LSTM ã§æ£å¼¦æ³¢ãäºæ¸¬ãã CHANGE LOG 2020/07/12 Sequenceã®é·ãã25 â 50ã§åå¦ç¿ãããå ´åãè¿½è¨ ã©ã¤ãã©ãªãã¹ã¿ã³ãã¢ãã³Keras â Tensorflow.kerasã«å¤æ´ ã©ã¤ãã©ãª from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation from tensorflow.keras.layers import LSTM from tensorflow.keras.optimizers impor
ã¯ããã« åå 㯠Python ã§ä½æããã¢ãã«ã«å¯¾ã㦠C++ ã§å¦ç¿ãè¡ãã¨ããã¾ã§èª¬æãã¾ããã ä»åã¯ï¼å¦ç¿ããã¢ãã«ã® freeze ã¨æ¨è«å¦çã®å®è¡ãè¡ãããã¨æãã¾ãã ä»åä½æããã³ã¼ãã¯åååæ§ github ã«ç½®ãã¦ããã®ã§ã詳細ã¯ãã¡ããã確èªãã ããã å®è¡ç°å¢ ï¼ååã¨åãã§ãï¼ Windows Python 3.6 keras 2.2.4 tensorflow 1.10.0 Visual Studio 2015 ãªããPython 㨠C++ ã§ä½¿ç¨ãã TensorFlow ã®ãã¼ã¸ã§ã³ã¯æãã¦ããªãã¨ã¨ã©ã¼ãçºçããå ´åãããããã§ãã C++ ç¨ã® tensorflow.dll ã¯ãã¡ãã®ãµã¤ããããã¦ã³ãã¼ããã¾ããã - GitHub - fo40225/tensorflow-windows-wheel: Tensorflow prebuilt bi
(2020/03/19) 以ä¸ã®ãªãªã¸ãã«ã®å 容ã¯TensorFlow 1.xã対象ã¨ãã¦ãã¾ããTensorFlow 2.xç³»ã§ç°ãªãç¹ãåºã¦ãã¾ããã®ã§ãå çãã¾ããã ã¯ããã« TensorFlowã®Tensorã£ã¦ä½ã ã£ãï¼ååãé£ãããã§é¢ãããããªãï¼ ã¨ããã¨ãã«ã¯ãnumpyã¨å¯¾æ¯ããªããæ¼ããã¦ããã¨åãããããã§ãã èªåãªãã®ç解ãã¾ã¨ãã¦ã¿ã¾ãã Tensorã£ã¦ä½ï¼ è¡åããã¯ãã«ãæ°å¤ãªã©ãä¸è¬åãããã¼ã¿ã§ããå¤æ¬¡å é åã®ã¤ã¡ã¼ã¸ã§ããã§ãããï¼0次å ã®é åã¨ããã®ã¯èãã«ããã§ããï¼ã ããã ããªãnumpyã®ndarrayã¨å¤ããã¾ããããTensorã«å¯¾ããæä½ã¯è¨å·çãªæä½ã§ãã£ã¦ãå®éã®è¨ç®ã¯ã¢ãã«ãå¦ç¿ããæãªã©å¿ è¦ã«ãªã£ãã¨ãã«åãã¦è¡ããã¾ãã(*) ãã®ããã Tensorãªãã¸ã§ã¯ãã«å ·ä½çãªå¤ã¯å ¥ã£ã¦ããªãããã¼ã¿ã®å½¢ç¶ï¼è¡åã®ãµã¤ãºã¨ã
ã¯ããã« ãã®è¨äºã¯ãååã®ç¶ç·¨ã§ãã å°å ¥é¨åã¯ååãåç §ããã ããã°ã¨æãã¾ãã ååã¯SimpleRNNã ä»åã¯ãLSTMã使ã£ã¦ã¢ãã«ãä½ãã¾ãã ï¼ï¼ã¢ãã«æ§ç¯ å¦ç¿ãã¼ã¿ã®ä½æé¨åã¯ååã¨åããªã®ã§å²æãã¾ãã ä»åã¯ãLSTMã¯ã©ã¹ã使ãã®ã§ãã¢ãã«æ§ç¯é¨åã¯ä¸è¨ã®ããã«ãªãã¾ãã ï¼SimpleRNNãLSTMã«ãªã£ãã ãï¼ model = Sequential() model.add(InputLayer(batch_input_shape=(None, maxlen, in_out_dims))) model.add( LSTM(units=hidden_dims, return_sequences=False)) model.add(Dense(in_out_dims)) model.add(Activation("linear")) model.compile(l
ã¯ããã« ãã®å 容ã¯ãèªèº«ã®ç¥èã®æ´çã主ãªç®çã§ãã å®è£ ããå 容ã¯ãå ¬å¼ããã¥ã¡ã³ããè²ã ãªäººã®å®è£ ä¾ãåèã«ãã¦ãã¾ããã ãªã«ã¶ããç¥èä¸è¶³ã«ããééã£ãç解ãããããããã¾ãããã ãã®æã¯ãé æ ®ãªããææé ããã¨å¹¸ãã§ããã ç°å¢ï¼ python 2.7.13 Keras 2.0.7 theano 0.9.0 scikit-learn 0.18.2 ããã㨠RNNã®ã·ã³ãã«ãªä¾ã使ã£ã¦ãKerasã§ã®å®è£ æ¹æ³ãå¦ã¶ã Kerasã§ã®ç°¡åãªRNNã®å®è£ ä¾ã¯CNNã¨æ¯ã¹ã¦å°ãªãã£ãã®ã§ãï¼ãããããï¼ï¼ èªåã§ä¾ãä½ã£ã¦ã¿ããã¨æãã¾ããã ãããã¨ã¯ãPeter's notesã®ä¾ã¨ã»ã¨ãã©åãã§ããã å¯å¤é·ã®æ°åã®ä¸¦ã³ãå ¥åã¨ãã¦ããã®ç·åãåºåã¨ãã¾ãã ä¾ï¼ no å ¥å(X) åºå(y)
æ失é¢æ°ã®å©ç¨æ¹æ³ æ失é¢æ°ï¼æ失é¢æ°ãæé©ã¹ã³ã¢é¢æ°ï¼ã¯ã¢ãã«ãã³ã³ãã¤ã«ããéã«å¿ è¦ãªãã©ã¡ã¼ã¿ã®1ã¤ã§ã: model.compile(loss='mean_squared_error', optimizer='sgd') from keras import losses model.compile(loss=losses.mean_squared_error, optimizer='sgd') æ¢åã®æ失é¢æ°ã®ååãå¼æ°ã«ä¸ãããï¼åãã¼ã¿ç¹ã«å¯¾ãã¦ã¹ã«ã©ãè¿ãï¼ä»¥ä¸ã®2ã¤ã®å¼æ°ãåãTensorFlow/Theanoã®ã·ã³ããªãã¯é¢æ°ãä¸ãããã¨ãã§ãã¾ã: y_true: æ£è§£ã©ãã«ï¼TensorFlow/Theano ãã³ã½ã« y_pred: äºæ¸¬å¤ï¼y_trueã¨åãshapeã®TensorFlow/Theano ãã³ã½ã« å®éã«æé©åãããç®çé¢æ°å¤ã¯å ¨ãã¼ã¿ç¹ã«ãããåº
åæã¨ãã¦ã以ä¸ã®è¨äºããã«TensorFLowSharpã®å°å ¥ãæ¸ãã§ãããã¨ã C#ã§TensorFlowãåããã ç´æ¥ãC#ã®ã³ã¼ãã§ã°ã©ããä½æãããã¨ããããã©ãããå 人ãã¡ã¯Pythonä¸ã§ã°ã©ããæ¸ããå¦ç¿ã¢ãã«ãä½æå¾ããããä»ã®è¨èªä¸ã§èªã¿è¾¼ãã§ããã ã¢ãã«ãèªã¿è¾¼ãéã«ãAndroidï¼Javaï¼ãC++ä¸ã§ãåæ§ã§ãããããã§ãã¯ãã¤ã³ã(ã·ãªã¢ã«åãããå¤æ°)ã®ã¨ã¯ã¹ãã¼ããã¼ã¿ãç´æ¥èªè¾¼ããã¨ã¯ã§ããªãã®ã§ããããã³ã«ãããã¡(ã·ãªã¢ã«åãããã°ã©ã)ã«ãã§ãã¯ãã¤ã³ãããã¼ã¸ããªããã°ä½¿ããã¨ãã§ããªããã¤ã¾ããå¤æ°ã®ç¶æ ããã¤ãããã³ã«ãããã¡ãä½æããã ã°ã©ãã¨ãã³ã½ã«ãã¼ã¿ã®ä¸¡æ¹ãåºåããããã«ã¯ãVariablesãConstantã«å¤æå¾ãå度ã°ã©ããä½æãã¦ProtocolBuffersãã¡ã¤ã«ã¨ãã¦åºåããå¿ è¦ãããã æ¹æ³ã¨ãã¦ã¯ã2ã¤ãã
import tensorflow as tf mnist = tf.keras.datasets.mnist (x_train, y_train),(x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(512, activation=tf.nn.relu), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation=tf.nn.softmax) ]) model.compile(opti
å帰ï¼çè²»ãäºæ¸¬ãã ã³ã¬ã¯ã·ã§ã³ã§ã³ã³ãã³ããæ´ç å¿ è¦ã«å¿ãã¦ãã³ã³ãã³ãã®ä¿åã¨åé¡ãè¡ãã¾ãã å帰åé¡ã§ã¯ãä¾¡æ ¼ã確çã¨ãã£ãé£ç¶çãªå¤ã®åºåãäºæ¸¬ãããã¨ãç®çã¨ãªãã¾ããããã¯ãåé¡åé¡ã®ç®çããï¼ãã¨ãã°ãåçã«ãªã³ã´ãåã£ã¦ããããªã¬ã³ã¸ãåã£ã¦ãããã¨ãã£ãï¼é¢æ£çãªã©ãã«ãäºæ¸¬ãããã¨ã§ããã®ã¨ã¯å¯¾ç §çã§ãã ãã®ãã¼ãããã¯ã§ã¯ãå¤å ¸ç㪠Auto MPG ãã¼ã¿ã»ããã使ç¨ãã1970 年代å¾åãã 1980 å¹´å°åãã®èªåè»ã®çè²»ãäºæ¸¬ããã¢ãã«ãæ§ç¯ãã¾ãããã®ç®çã®ãããã¢ãã«ã«ã¯ãã®ææã®å¤æ°ã®èªåè»ã®ä»æ§ãèªã¿è¾¼ã¾ãã¾ããä»æ§ã«ã¯ãæ°çæ°ãææ°éã馬åãééãªã©ãå«ã¾ãã¦ãã¾ãã ãã®ãµã³ãã«ã§ã¯tf.keras APIã使ç¨ãã¦ãã¾ãã詳細ã¯ãã®ã¬ã¤ããåç §ãã¦ãã ããã # Use seaborn for pairplot. pip install
ã¯ããã« TensorFlow2 + Keras ãå©ç¨ããç»ååé¡ï¼Google Colaboratory ç°å¢ï¼ã«ã¤ãã¦ã®åå¼·ã¡ã¢ï¼ç¬¬6å¼¾ï¼ã§ããé¡æã¯ããå®çªã§ããææ¸ãæ°åç»åï¼MNISTï¼ã®åé¡ã§ãã TensorFlow2 + Keras ã«ããç»ååé¡ã«ææ¦ ã·ãªã¼ãº 1. ã¨ããããåãã 2. å ¥åãã¼ã¿ã詳ããã¿ã¦ã¿ã 3. MNISTãã¼ã¿ãå¯è¦åãã¦ã¿ã 4. å¦ç¿æ¸ã¿ã¢ãã«ã§äºæ¸¬ããã¦ã¿ã 5. åé¡ã«å¤±æããç»åã観å¯ãã¦ã¿ã 6. èªåã§ç¨æããç»åã®åå¦çã»åé¡ããã¦ã¿ã 7. 層ã¿ã¤ãã»æ´»æ§åé¢æ°ã«ã¤ãã¦ç解ãã 8. æé©åã¢ã«ã´ãªãºã ã¨æ失é¢æ°ãé¸æãã 9. ã¢ãã«ã®å¦ç¿ãã»ã¼ãï¼ãã¼ãããã¦ã¿ã ååã¯ãããããã MNIST ã§ç¨æããã¦ããææ¸ãæ°åã¤ã¡ã¼ã¸ã使ã£ã¦äºæ¸¬ï¼åé¡ï¼ãè¡ãªãã¾ãããä»åã¯ãèªåã§ç¨æããç»åã使ã£ã¦ãå¦ç¿æ¸ã¿ã«ã¢ãã«
ã¯ããã« TensorFlow2 + Keras ãå©ç¨ããç»ååé¡ï¼Google Colaboratory ç°å¢ï¼ã«ã¤ãã¦ã®åå¼·ã¡ã¢ï¼ç¬¬1å¼¾ï¼ã§ããé¡æã¯ããå®çªã§ããææ¸ãæ°åç»åï¼MNISTï¼ã®åé¡ã§ãã TensorFlow2 + Keras ã«ããç»ååé¡ã«ææ¦ ã·ãªã¼ãº 1. ã¨ããããåãã 2. å ¥åãã¼ã¿ã詳ããã¿ã¦ã¿ã 3. MNISTãã¼ã¿ãå¯è¦åãã¦ã¿ã 4. å¦ç¿æ¸ã¿ã¢ãã«ã§äºæ¸¬ããã¦ã¿ã 5. åé¡ã«å¤±æããç»åã観å¯ãã¦ã¿ã 6. èªåã§ç¨æããç»åã®åå¦çã»åé¡ããã¦ã¿ã 7. 層ã¿ã¤ãã»æ´»æ§åé¢æ°ã«ã¤ãã¦ç解ãã 8. æé©åã¢ã«ã´ãªãºã ã¨æ失é¢æ°ãé¸æãã 9. ã¢ãã«ã®å¦ç¿ãã»ã¼ãï¼ãã¼ãããã¦ã¿ã å ·ä½çã«ã¯ã次ã®ãããª**ã0ãããã9ãã¾ã§ã®ææ¸ãæåãåãè¾¼ãã ç»å**ï¼28x28pixelï¼ã対象ã«ã ããããã®ç»åã**ã0ãããã9ãã®ã©
Pythonï¼TensorFlow GPU ç 2.10, Keras, scikit-learn, MatplotLib, Python ç¨ opencv-python ã®ã¤ã³ã¹ãã¼ã«ï¼Windows ä¸ï¼ ãè¦ç´ã Windowsä¸ã§Pythonåã³é¢é£ããã±ã¼ã¸ï¼TensorFlow GPUç2.10ï¼Kerasï¼scikit-learnï¼MatplotLibï¼opencv-pythonï¼ã®ã¤ã³ã¹ãã¼ã«æé ã説æãã¦ããï¼ä¸»ãªå 容ã¨ãã¦ï¼Pythonã¨Gitï¼7-Zipã®ã¤ã³ã¹ãã¼ã«ï¼NVIDIAé¢é£ã½ããã¦ã§ã¢ï¼ãã©ã¤ãï¼CUDAãã¼ã«ãããï¼cuDNNï¼ã®ã»ããã¢ããï¼TensorFlowã¨ä»ã®ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«ï¼ç°å¢å¤æ°ã®è¨å®ï¼ããã¦åä½ç¢ºèªã®æ¹æ³ã説æãã¦ããï¼ã³ãã³ãããã³ããã使ç¨ããã¤ã³ã¹ãã¼ã«æé ï¼åã¹ãããã§ã®æ³¨æç¹ã説æãã¦ããï¼GPUã®èªè確èªãç°¡åãªTe
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}