Start studying: Saturday, December 7th
Teaching materials, etc .: ・ Miyuki Oshige "Details! Python3 Introductory Note ”(Sotec, 2017): 12/7 (Sat) -12/19 (Thu) read ・ Progate Python course (5 courses in total): 12/19 (Thursday) -12/21 (Saturday) end ・ Andreas C. Müller, Sarah Guido "(Japanese title) Machine learning starting with Python" (O'Reilly Japan, 2017): 12/21 (Sat) -December 23 (Sat) ・ Kaggle: Real or Not? NLP with Disaster Tweets: Posted on Saturday, December 28th to Friday, January 3rd Adjustment ・ Wes Mckinney "(Japanese title) Introduction to data analysis by Python" (O'Reilly Japan, 2018): 1/4 (Wednesday) to 1/13 (Monday) read ・ Yasuki Saito "Deep Learning from Zero" (O'Reilly Japan, 2016): 1/15 (Wed) -1/20 (Mon) ・ ** François Chollet “Deep Learning with Python and Keras” (Queep, 2018): 1/21 (Tue) ~ **
p.94 Chapter 3 Finished reading up to the neural network.
Regression model with keras
from keras import models
from keras import layers
def build_model():
#You can add layers with add. This time it consists of two layers
model = models.Sequential()
#input(input_shape)A hidden layer is created with 64 units, and the activation function is ReLU.
model.add(layers.Dense(64, activation = 'relu',
input_shape=(train_data.shape[1],)))
#2nd layer
model.add(layers.Dense(64, activation = 'relu'))
#Since it is a final layer scalar regression problem, the activation function is not applied. (The number width is fixed.)
model.add(layers.Dense(1))
#Weight adjustment optimizer is rmsprop, loss function is mse, index is mae
model.compile(optimizer='rmsprop', loss='mse', metrics=['mae'])
return model
I have no idea what the comma ** after ** shape [1] of the 3rd argument input_shape in the 1st layer means, and if I remove the comma because I think it is unnecessary, I will throw an error, so I will search for various things. While turning around, I found the following article
What does TensorFlow shape (?,) mean? (stackoverflow)
Apparently, the comma is used to get a tensor that takes any dimension.
And after doing so far
python
train_data.shape[1] = 13
input_shape(13, )
I noticed that. It was like slicing, and I made a misunderstanding that it was a special process of putting a comma outside the list [].
If you get stuck, it's important to first read the structure without rushing, and then subdivide and understand it one by one.
Recommended Posts