शुरू करेंमुफ़्त में शुरू करें

अंकों को सीखना

आप digits dataset पर एक मॉडल बनाएँगे, जो scikit-learn के साथ प्री-लोड आता है. digits dataset में 0 से 9 तक के 8x8 पिक्सेल के हस्तलिखित अंक हैं:

आपको इमेज के आधार पर 10 संभावित अंकों में से सही अंक पहचानना है, इसलिए यह multi-class classification की समस्या है.

डेटासेट पहले से X_train, y_train, X_test, और y_test में बाँटा गया है, जिसमें 30% डेटा testing के लिए है. लेबल पहले से one-hot encoded vectors हैं, इसलिए आपको Keras की to_categorical() फंक्शन उपयोग करने की ज़रूरत नहीं है.

आइए इस नए model को बनाते हैं!

यह अभ्यास पाठ्यक्रम का हिस्सा है

Keras के साथ डीप लर्निंग परिचय

पाठ्यक्रम देखें

अभ्यास निर्देश

  • 16 न्यूरॉनों वाली एक Dense लेयर जोड़ें, relu activation के साथ, और ऐसा input_shape दें जो 8x8 अंक इमेज के कुल पिक्सेल लेता हो.
  • 10 आउटपुट और softmax activation वाली एक Dense लेयर जोड़ें.
  • अपने मॉडल को adam, categorical_crossentropy, और accuracy metrics के साथ compile करें.
  • X_train पर prediction करके सुनिश्चित करें कि आपका मॉडल काम कर रहा है.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Instantiate a Sequential model
model = Sequential()

# Input and hidden layer with input_shape, 16 neurons, and relu 
model.add(Dense(____, input_shape = (____,), activation = ____))

# Output layer with 10 neurons (one per digit) and softmax
model.____(____)

# Compile your model
model.____(optimizer = ____, loss = ____, metrics = [____])

# Test if your model is well assembled by predicting before training
print(model.predict(____))
कोड संपादित करें और चलाएँ