tensorflow.python.framework.errors_impl.InternalError:  Blas GEMM launch failed : a.shape=(32, 784), b.shape=(784, 128), m=32, n=128, k=784

            [[node sequential/dense/MatMul (defined at O:/PycharmProjects/catdogtf2.2/002.py:58) ]] [Op:__inference_train_function_542]

 

Blas GEMM launch failed : pyCharm 껐다 켜면 됨. 무적의 옵앤온(off&on)

 

O:\PycharmProjects\catdogtf2.2\venv\Scripts\python.exe O:\PyCharm\plugins\python\helpers\pydev\pydevconsole.py --mode=client --port=51027

import sys; print('Python %s on %s' % (sys.version, sys.platform))

sys.path.extend(['O:\\PycharmProjects\\catdogtf2.2', 'O:/PycharmProjects/catdogtf2.2'])

PyDev console: starting.

Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] on win32

>>> runfile('O:/PycharmProjects/catdogtf2.2/002.py', wdir='O:/PycharmProjects/catdogtf2.2')

2020-08-11 05:03:54.636978: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

2.2.0

2020-08-11 05:03:59.300858: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll

2020-08-11 05:03:59.345092: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:

pciBusID: 0000:09:00.0 name: GeForce RTX 2080 SUPER computeCapability: 7.5

coreClock: 1.845GHz coreCount: 48 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 462.00GiB/s

2020-08-11 05:03:59.345646: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

2020-08-11 05:03:59.354065: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll

2020-08-11 05:03:59.359976: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll

2020-08-11 05:03:59.363292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll

2020-08-11 05:03:59.370767: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll

2020-08-11 05:03:59.375232: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll

2020-08-11 05:03:59.402544: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll

2020-08-11 05:03:59.402886: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0

2020-08-11 05:03:59.403354: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

2020-08-11 05:03:59.413780: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x17b3e2401b0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:

2020-08-11 05:03:59.414181: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version

2020-08-11 05:03:59.414663: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:

pciBusID: 0000:09:00.0 name: GeForce RTX 2080 SUPER computeCapability: 7.5

coreClock: 1.845GHz coreCount: 48 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 462.00GiB/s

2020-08-11 05:03:59.415114: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

2020-08-11 05:03:59.415306: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll

2020-08-11 05:03:59.415512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll

2020-08-11 05:03:59.415727: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll

2020-08-11 05:03:59.415931: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll

2020-08-11 05:03:59.416156: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll

2020-08-11 05:03:59.416363: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll

2020-08-11 05:03:59.416598: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0

2020-08-11 05:04:00.086495: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:

2020-08-11 05:04:00.086665: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0

2020-08-11 05:04:00.086839: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N

2020-08-11 05:04:00.087157: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6198 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 SUPER, pci bus id: 0000:09:00.0, compute capability: 7.5)

2020-08-11 05:04:00.091100: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x17b8d4b5440 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:

2020-08-11 05:04:00.091383: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce RTX 2080 SUPER, Compute Capability 7.5

Epoch 1/5

2020-08-11 05:04:00.883945: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll

1875/1875 [==============================] - 4s 2ms/step - loss: 0.4979 - accuracy: 0.8245

Epoch 2/5

1875/1875 [==============================] - 4s 2ms/step - loss: 0.3748 - accuracy: 0.8647

Epoch 3/5

1875/1875 [==============================] - 3s 2ms/step - loss: 0.3337 - accuracy: 0.8779

Epoch 4/5

1875/1875 [==============================] - 3s 2ms/step - loss: 0.3118 - accuracy: 0.8850

Epoch 5/5

1875/1875 [==============================] - 3s 2ms/step - loss: 0.2945 - accuracy: 0.8916

313/313 - 1s - loss: 0.3482 - accuracy: 0.8756

테스트 정확도: 0.8755999803543091

 

# tensorflow tf.keras를 임포트합니다

import tensorflow as tf

from tensorflow import keras

 

# 헬퍼(helper) 라이브러리를 임포트합니다

import numpy as np

import matplotlib.pyplot as plt

 

print(tf.__version__)

 

fashion_mnist = keras.datasets.fashion_mnist

 

(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

 

class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',

               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']

 

train_images.shape

 

len(train_labels)

 

train_labels

 

test_images.shape

 

len(test_labels)

 

plt.figure()

plt.imshow(train_images[0])

plt.colorbar()

plt.grid(False)

plt.show()

 

train_images = train_images / 255.0

 

test_images = test_images / 255.0

 

plt.figure(figsize=(10,10))

for i in range(25):

    plt.subplot(5,5,i+1)

    plt.xticks([])

    plt.yticks([])

    plt.grid(False)

    plt.imshow(train_images[i], cmap=plt.cm.binary)

    plt.xlabel(class_names[train_labels[i]])

plt.show()

 

model = keras.Sequential([

    keras.layers.Flatten(input_shape=(28, 28)),

    keras.layers.Dense(128, activation='relu'),

    keras.layers.Dense(10, activation='softmax')

])

 

model.compile(optimizer='adam',

              loss='sparse_categorical_crossentropy',

              metrics=['accuracy'])

 

model.fit(train_images, train_labels, epochs=5)

 

test_loss, test_acc = model.evaluate(test_images,  test_labels, verbose=2)

 

print('\n테스트 정확도:', test_acc)

 

predictions = model.predict(test_images)

 

predictions[0]

 

np.argmax(predictions[0])

 

test_labels[0]

 

def plot_image(i, predictions_array, true_label, img):

  predictions_array, true_label, img = predictions_array[i], true_label[i], img[i]

  plt.grid(False)

  plt.xticks([])

  plt.yticks([])

 

  plt.imshow(img, cmap=plt.cm.binary)

 

  predicted_label = np.argmax(predictions_array)

  if predicted_label == true_label:

    color = 'blue'

  else:

    color = 'red'

 

  plt.xlabel("{} {:2.0f}% ({})".format(class_names[predicted_label],

                                100*np.max(predictions_array),

                                class_names[true_label]),

                                color=color)

 

def plot_value_array(i, predictions_array, true_label):

  predictions_array, true_label = predictions_array[i], true_label[i]

  plt.grid(False)

  plt.xticks([])

  plt.yticks([])

  thisplot = plt.bar(range(10), predictions_array, color="#777777")

  plt.ylim([0, 1])

  predicted_label = np.argmax(predictions_array)

 

  thisplot[predicted_label].set_color('red')

  thisplot[true_label].set_color('blue')

 

i = 0

plt.figure(figsize=(6,3))

plt.subplot(1,2,1)

plot_image(i, predictions, test_labels, test_images)

plt.subplot(1,2,2)

plot_value_array(i, predictions,  test_labels)

plt.show()

 

i = 12

plt.figure(figsize=(6,3))

plt.subplot(1,2,1)

plot_image(i, predictions, test_labels, test_images)

plt.subplot(1,2,2)

plot_value_array(i, predictions,  test_labels)

plt.show()

 

# 처음 X 개의 테스트 이미지와 예측 레이블, 진짜 레이블을 출력합니다

# 올바른 예측은 파랑색으로 잘못된 예측은 빨강색으로 나타냅니다

num_rows = 5

num_cols = 3

num_images = num_rows*num_cols

plt.figure(figsize=(2*2*num_cols, 2*num_rows))

for i in range(num_images):

  plt.subplot(num_rows, 2*num_cols, 2*i+1)

  plot_image(i, predictions, test_labels, test_images)

  plt.subplot(num_rows, 2*num_cols, 2*i+2)

  plot_value_array(i, predictions, test_labels)

plt.show()

 

# 테스트 세트에서 이미지 하나를 선택합니다

img = test_images[0]

 

print(img.shape)

 

# 이미지 하나만 사용할 때도 배치에 추가합니다

img = (np.expand_dims(img,0))

 

print(img.shape)

 

predictions_single = model.predict(img)

 

print(predictions_single)

 

plot_value_array(0, predictions_single, test_labels)

_ = plt.xticks(range(10), class_names, rotation=45)

 

np.argmax(predictions_single[0])

 

 

#

# Copyright (c) 2017 François Chollet

#

# Permission is hereby granted, free of charge, to any person obtaining a

# copy of this software and associated documentation files (the "Software"),

# to deal in the Software without restriction, including without limitation

# the rights to use, copy, modify, merge, publish, distribute, sublicense,

# and/or sell copies of the Software, and to permit persons to whom the

# Software is furnished to do so, subject to the following conditions:

#

# The above copyright notice and this permission notice shall be included in

# all copies or substantial portions of the Software.

#

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

# DEALINGS IN THE SOFTWARE.

 

 

 

 

 

 

 

 

테스트 정확도: 0.8712000250816345

(28, 28)

(1, 28, 28)

[[1.18709238e-08 2.98055518e-08 5.65596814e-09 2.69023825e-08

  2.10091784e-08 4.35429800e-04 2.36874556e-07 1.28662065e-02

  5.69078793e-06 9.86692369e-01]]

 

 

+ Recent posts