softmax多分类 onehot编码

import matplotlib.pyplot as plt
import gzip
import numpy as np
import os
import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import os

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"

os.environ["CUDA_VISIBLE_DEVICES"] = "1"

print(tf.__version__)
gpus =tf.config.experimental.list_physical_devices(device_type= 'GPU')
cpus= tf.config. experimental.list_physical_devices(device_type= 'CPU')
print(gpus)
print(cpus)
print("tensorflow-gpu:",tf.test.is_gpu_available())

#指定在GP上执行随机数操作
with tf.device('/gpu:0'):
    gpu_a= tf.random.normal([10000, 1000])
    gpu_b= tf.random.normal([1000,2000])
    gpu_c = tf.matmul(gpu_a, gpu_b)

print("gpu_a:",gpu_a.device)
print("gpu b:", gpu_b.device)
print("gpu c:", gpu_c.device)

def load_data(path,files):

    paths = [path+ each for each in files ]
    with gzip.open(paths[0], 'rb') as lbpath:
        train_labels = np.frombuffer(lbpath.read(), np.uint8, offset=8)
    with gzip.open(paths[1], 'rb') as impath:
  

你可能感兴趣的:(深度学习,神经网络)