-
大小: 1.04MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-09-30
- 语言: 其他
- 标签: cs231n assignment2 深度学习
资源简介
斯坦福cs231n的assignment2,完整代码
代码片段和文件信息
import cPickle as pickle
import numpy as np
import os
from scipy.misc import imread
def load_CIFAR_batch(filename):
“““ load single batch of cifar “““
with open(filename ‘rb‘) as f:
datadict = pickle.load(f)
X = datadict[‘data‘]
Y = datadict[‘labels‘]
X = X.reshape(10000 3 32 32).transpose(0231).astype(“float“)
Y = np.array(Y)
return X Y
def load_CIFAR10(ROOT):
“““ load all of cifar “““
xs = []
ys = []
for b in range(16):
f = os.path.join(ROOT ‘data_batch_%d‘ % (b ))
X Y = load_CIFAR_batch(f)
xs.append(X)
ys.append(Y)
Xtr = np.concatenate(xs)
Ytr = np.concatenate(ys)
del X Y
Xte Yte = load_CIFAR_batch(os.path.join(ROOT ‘test_batch‘))
return Xtr Ytr Xte Yte
def get_CIFAR10_data(num_training=49000 num_validation=1000 num_test=1000):
“““
Load the CIFAR-10 dataset from disk and perform preprocessing to prepare
it for classifiers. These are the same steps as we used for the SVM but
condensed to a single function.
“““
# Load the raw CIFAR-10 data
cifar10_dir =‘/Users/pangjia/Documents/deep_learning/cifar-10-batches-py‘
#cifar10_dir = ‘cs231n/datasets/cifar-10-batches-py‘
X_train y_train X_test y_test = load_CIFAR10(cifar10_dir)
# Subsample the data
mask = range(num_training num_training + num_validation)
X_val = X_train[mask]
y_val = y_train[mask]
mask = range(num_training)
X_train = X_train[mask]
y_train = y_train[mask]
mask = range(num_test)
X_test = X_test[mask]
y_test = y_test[mask]
# Normalize the data: subtract the mean image
mean_image = np.mean(X_train axis=0)
X_train -= mean_image
X_val -= mean_image
X_test -= mean_image
# Transpose so that channels come first
X_train = X_train.transpose(0 3 1 2).copy()
X_val = X_val.transpose(0 3 1 2).copy()
X_test = X_test.transpose(0 3 1 2).copy()
# Package data into a dictionary
return {
‘X_train‘: X_train ‘y_train‘: y_train
‘X_val‘: X_val ‘y_val‘: y_val
‘X_test‘: X_test ‘y_test‘: y_test
}
def load_tiny_imagenet(path dtype=np.float32):
“““
Load TinyImageNet. Each of TinyImageNet-100-A TinyImageNet-100-B and
TinyImageNet-200 have the same directory structure so this can be used
to load any of them.
Inputs:
- path: String giving path to the directory to load.
- dtype: numpy datatype used to load the data.
Returns: A tuple of
- class_names: A list where class_names[i] is a list of strings giving the
WordNet names for class i in the loaded dataset.
- X_train: (N_tr 3 64 64) array of training images
- y_train: (N_tr) array of training labels
- X_val: (N_val 3 64 64) array of validation images
- y_val: (N_val) array of validation labels
- X_test: (N_test 3 64 64) array of testing images.
- y_test: (N_test) array of test labels; if test labels are not available
(such as in student code) t
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8196 2017-04-25 08:21 .DS_Store
文件 220808 2017-04-13 06:37 BatchNormalization.ipynb
文件 378020 2017-04-21 08:01 ConvolutionalNetworks.ipynb
目录 0 2017-04-21 07:59 cs231n\
文件 6148 2017-04-21 06:33 cs231n\.DS_Store
文件 0 2016-01-22 09:31 cs231n\__init__.py
目录 0 2017-04-21 07:47 cs231n\classifiers\
文件 0 2016-01-22 09:31 cs231n\classifiers\__init__.py
文件 6223 2017-04-21 07:47 cs231n\classifiers\cnn.py
文件 18049 2017-04-12 08:21 cs231n\classifiers\fc_net.py
文件 6935 2017-03-29 00:14 cs231n\data_utils.py
文件 9288 2016-01-22 09:31 cs231n\fast_la
文件 3568 2016-01-22 09:31 cs231n\gradient_check.py
文件 2090 2016-01-22 09:31 cs231n\im2col.py
文件 1161927 2017-04-21 06:33 cs231n\im2col_cython.c
文件 4982 2016-01-22 09:31 cs231n\im2col_cython.pyx
文件 298104 2017-04-21 06:34 cs231n\im2col_cython.so
文件 2445 2017-03-29 02:11 cs231n\la
文件 31814 2017-04-13 01:58 cs231n\la
文件 6545 2017-04-13 06:37 cs231n\optim.py
文件 298 2016-01-22 09:31 cs231n\setup.py
文件 10446 2017-03-29 02:16 cs231n\solver.py
文件 1951 2016-01-22 09:31 cs231n\vis_utils.py
文件 50774 2017-04-25 08:19 Dropout.ipynb
文件 412 2016-01-22 09:31 fr
文件 463514 2017-04-25 08:20 FullyConnectedNets.ipynb
文件 21355 2016-01-22 09:31 kitten.jpg
文件 38392 2016-01-22 09:31 puppy.jpg
文件 113 2016-01-22 09:31 start_ipython_osx.sh
- 上一篇:个人博客网站网页设计期末作业
- 下一篇:局域网抢答器V1.1含注册机
相关资源
- 《TensorFlow Keras 深度学习人工智能实践
- TensorFlow+on+Yarn:深度学习遇上大数据
- 大数据和深度学习
- 深度学习讲座
- 基于深度学习目标检测算法综述
- opencv4.0结合TensorFlow实现mask rcnn的目标
- 深度学习word2vec学习笔记.docx
- 深度学习笔记之RBM修正版
- 《深度学习》自建搜狗各学科中文词
- 生成对抗网络的技术与应用
- keras实现的VGGface 特征提取,用来抽取
- 行为识别综述
- 高分辨率遥感影像的深度学习变化检
- 无痛的机器学习 第一季
- 神经网络与深度学习吴恩达第三周编
- 基于深度学习的语音识别
- 深度学习基础教程资源汇总
- 基于深度学习的刀具磨损状态监测技
- 基于深度学习和强化学习的车辆定位
- Deep Learning with PyTorch 完整版
- Keras图像深度学习实战原版
- 基于深度学习的图像去噪算法研究.
- TENSORRT 轻松部署高性能DNN推理
- 基于深度学习的图像语义分割算法综
- rcnn、fast rcnn、faster rcnn和yolo的算法原
- caffe深度学习薛开宇笔记-基于卷积神
- Deep Learning Cookbook
- cs231N中文版笔记
- 人工智能及其应用第4版
- 斯坦福UFLDL深度学习课程翻译版合集
评论
共有 条评论