Ai
1 Star 0 Fork 0

Houor/ml-py

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cifar_tf.py 906 Bytes
一键复制 编辑 原始数据 按行查看 历史
Houor 提交于 2019-12-02 01:10 +08:00 . matplotlib1
import os
import sys
import numpy as np
import tensorflow as tf
from tensorflow import keras
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
np.set_printoptions(linewidth=1000)
# 加载CIFAR10数据,以numpy形式返回,分割为50000/10000两部分
(x, y), (x_val, y_val) = keras.datasets.cifar10.load_data()
print('training dataset shape: ', x.shape, y.shape) # (50000, 32, 32, 3) (50000, 1)
print('testing dataset shape: ', x_val.shape, y_val.shape) # (10000, 28, 28) (10000,)
print('x[0] in training dataset: \n', x[0], sep='\t', end='\n', file=sys.stdout)
train_dataset = tf.data.Dataset.from_tensor_slices((x, y))
# data shuffle
train_dataset.shuffle(10000)
# data pre-processing
def preprocess(x, y):
x = tf.cast(x, dtype=tf.float32) / 255.
y = tf.cast(y, dtype=tf.float32)
res = next(iter(train_dataset))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/houor/ml-py.git
git@gitee.com:houor/ml-py.git
houor
ml-py
ml-py
master

搜索帮助