Lädt...

🔧 https://rb.gy/81ytn0


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

TensorFlowを用いた画像分類の基本

はじめに

TensorFlowは画像分類の実装に最適なライブラリの一つです。本記事では、TensorFlowを用いて画像分類モデルを構築し、実際に動作させる方法を解説します。

画像分類の概念

画像分類は、一般的なタスクである「特徴抽出」と「分類器の構築」からなります。CNNは、画像から関連する特徴を抽出し、分類器で判定する仕組みを持っています。

TensorFlowでのデータ前処理

画像分類のために、先にデータの前処理を行います。

import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator

datagen = ImageDataGenerator(rescale=1./255)
dataset = datagen.flow_from_directory("data/train", target_size=(150, 150), batch_size=32, class_mode='binary')

CNNの構築

CNNは、複数の小さなフィルタを通じて特徴を抽出する機構です。

from tensorflow.keras import layers, models

model = models.Sequential([
    layers.Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 3)),
    layers.MaxPooling2D((2, 2)),
    layers.Conv2D(64, (3, 3), activation='relu'),
    layers.MaxPooling2D((2, 2)),
    layers.Conv2D(128, (3, 3), activation='relu'),
    layers.MaxPooling2D((2, 2)),
    layers.Flatten(),
    layers.Dense(512, activation='relu'),
    layers.Dense(1, activation='sigmoid')
])

model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

モデルの学習と評価

history = model.fit(dataset, epochs=10)

おわりに

TensorFlowを使うことで、実際に画像を分類する機械学習モデルを構築できます。

...

🔧 https://rb.gy/81ytn0


📈 42.68 Punkte
🔧 Programmierung

📰 HTTPS-Interception: Sicherheitsprodukte gefährden HTTPS


📈 8.63 Punkte
📰 IT Nachrichten

🕵️ Firefox 83 released with 'HTTPS-Only Mode' that only loads HTTPS sites


📈 8.63 Punkte
🕵️ Hacking

📰 HTTPS-Interception: Sicherheitsprodukte gefährden HTTPS


📈 8.63 Punkte
📰 IT Security Nachrichten

🕵️ Stripo Inc: Unrestricted File Upload on https://my.stripo.email and https://stripo.email


📈 8.63 Punkte
🕵️ Sicherheitslücken

📰 How Does HTTPS Work to Keep Us Safe? (HTTP vs HTTPS Explained)


📈 8.63 Punkte
🖥️ Betriebssysteme

🔧 Nginx force http to https On 443 https Port


📈 8.63 Punkte
🔧 Programmierung

📰 You like HTTPS. We like HTTPS. Except when a quirk of TLS can smash someone's web privacy


📈 8.63 Punkte
📰 IT Security Nachrichten

🔧 HTTPS: How HTTPS Works - Handshake


📈 8.63 Punkte
🔧 Programmierung

📰 HTTPS Explained: HTTP vs HTTPS and What You Should Know


📈 8.63 Punkte
🖥️ Betriebssysteme

🕵️ https://formularios-admin.qa.insivumeh.gob.gt


📈 4.31 Punkte
🕵️ Hacking

🕵️ https://munisantamariadelvalle.gob.pe/xaad.html


📈 4.31 Punkte
🕵️ Hacking

🕵️ https://www.psa.gov


📈 4.31 Punkte
🕵️ Hacking

matomo