rem mat
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Malte Grosse 2023-11-30 09:58:35 +09:00
parent c1c2795e42
commit 45d58b7723
1 changed files with 52 additions and 2 deletions

54
run.py
View File

@ -1,6 +1,6 @@
import tensorflow as tf
from tensorflow import keras
import matplotlib.pyplot as plt
import numpy as np
import os
# Version Information
@ -26,4 +26,54 @@ print(tf.test.is_built_with_cuda())
(X_train, y_train), (X_test,y_test) = tf.keras.datasets.cifar10.load_data()
print(X_train.shape,y_train.shape)
print(X_train.shape,y_train.shape)
classes = ["airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"]
print(classes[y_train[3][0]])
print("pre processing: scale images")
X_train_scaled = X_train / 255
X_test_scaled = X_test / 255
y_train_categorical = keras.utils.to_categorical(
y_train, num_classes=10, dtype='float32'
)
y_test_categorical = keras.utils.to_categorical(
y_test, num_classes=10, dtype='float32'
)
print("model build")
model = keras.Sequential([
keras.layers.Flatten(input_shape=(32,32,3)),
keras.layers.Dense(300, activation='relu'),
keras.layers.Dense(100, activation='relu'),
keras.layers.Dense(10, activation='sigmoid')
])
model.compile(optimizer='SGD',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(X_train_scaled, y_train_categorical, epochs=1)
def get_model():
model = keras.Sequential([
keras.layers.Flatten(input_shape=(32,32,3)),
keras.layers.Dense(3000, activation='relu'),
keras.layers.Dense(1000, activation='relu'),
keras.layers.Dense(10, activation='sigmoid')
])
model.compile(optimizer='SGD',
loss='categorical_crossentropy',
metrics=['accuracy'])
return model
with tf.device('/GPU:0'):
cpu_model = get_model()
cpu_model.fit(X_train_scaled, y_train_categorical, epochs=10)
print("done")