图灵程序丛书 —《数据科学入门》— Ch1 导论

一个tail bound定理 一些基础: Markov不等式:为非负随机变量, Chebyshev不等式: Markov不等式的推论:当r为偶数时,有 注记: Markov不等式要求X是非负随机变量,给出的界随着a的增长,以的速率下降 Chebyshev不等式不要求X是非负随机变量,给出的界随着a的增长,以的速率下降 推论不等式在r为偶数的时候成立,给出的界随着a的增长,以的速率下降 如果相较于, 等低阶矩增加的不是很多,被某种上界所限制,则推论效果会比较好,可以获得更紧的界(r越大,界越紧); 定理的Intuit. 阅读详情

Ch1 导论

此系列记录《数据科学入门》学习笔记

1.3.1 寻找关键联系人

1、定义users字典list

users = [
    {'id': 0, 'name': 'Hero'},
    {'id': 1, 'name': 'Dunn'},
    {'id': 2, 'name': 'Sue'},
    {'id': 3, 'name': 'Chi'},
    {'id': 4, 'name': 'Thor'},
    {'id': 5, 'name': 'Clive'},
    {'id': 6, 'name': 'Hicks'},
    {'id': 7, 'name': 'Devin'},
    {'id': 8, 'name': 'Kate'},
    {'id': 9, 'name': 'Klein'},
]

2、定义友邻关系list

friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)]

3、在users添加friends列

for user in users:
    user['friends'] = []
for i ,j in friendships:
    users[i]['friends'].append(users[j])
    users[j]['friends'].append(users[i])

4、计算友邻关系的联系数

# 计算全部联系数
def number_of_friends(user):
    """how many friends dose _user_ have?"""
    return len(user['friends'])
total_connections = sum(number_of_friends(user) for user in users)
total_connections
# 计算平均联系数
# from __future__ import division  导入整数除法,python3不需要这样操作
num_users = len(users)
avg_connections = total_connections / num_users
avg_connections

5、对users按照朋友数排序

# 按照朋友数目排序,得到(id,number)
num_friends_by_id = [(user['id'], number_of_friends(user)) for user in users]
sorted(num_friends_by_id, key=lambda x: x[1], reverse=True) #表示从大到小排序

1.3.2 你可能知道的科学家
1、对users内用户计算朋友的朋友
# 计算朋友的朋友
def friends_of_friend_ids_bad(user):
    # foaf 是朋友的朋友 英文缩写
    return [foaf['id']
        for friend in user['friends']
        for foaf in friend['friends']]
friends_of_friend_ids_bad(users[0])  #[0, 2, 3, 0, 1, 3]
# 1,2是0的朋友;0,2,3是1的朋友;0,1,3是2的朋友
print([friend['id'] for friend in users[0]['friends']])
print([friend['id'] for friend in users[1]['friends']])
print([friend['id'] for friend in users[2]['friends']])

2、找到用户与其他用户相同好友数
# 计算共同朋友
from collections import Counter
# Counter是一个简单的计数器,例如,统计字符出现的个数


def not_the_same(user, other_user):
    """two users are not the same if they have different ids"""
    return user['id'] != other_user['id']


def not_friends(user, other_user):
    """other_user is not a friend if he's not in user['friends],
    that is, if he's not_the_same as all the people in user['friends]"""
    return all(not_the_same(friend, other_user) for friend in user['friends'])


def friends_of_friend_ids(user):
    return Counter(foaf['id'] 
                   for friend in user['friends']
                   for foaf in friend['friends']
                   if not_the_same(user, foaf) and not_friends(user, foaf))
print(friends_of_friend_ids(users[3]))
# Counter({0: 2, 5: 1}) 说明3和2有两个共同好友,3和5有一个共同好友

3、寻找相同爱好的用户
interests = [(0,"Hadoop"),(0,"Big Data"),(0,"HBase"),(0,"Java"),(0,"Spark"),(0,"Storm"),
             (0,"Cassandra"),
             (1,"NoSQL"),(1,"MongoDB"),(1,"Cassandra"),(1,"HBase"),(1,"Postgres"),
             (2,"Python"),(2,"scikit-learn"),(2,"Scipy"),(2,"numpy"),(2,"satasmodels"),
             (2,"pandas"),
             (3,"R"),(3,"Python"),(3,"Statistics"),(3,"regression"),(3,"probability"),
             (4,"machine learning"),(4,"regression"),(4,"decision trees"),(4,"libsvm"),
             (5,"Python"),(5,"R"),(5,"Java"),(5,"C++"),(5,"Haskell"),
             (5,"programing languages"),
             (6,"statistics"),(6,"probability"),(6,"machine learning"),(6,"theory"),
             (7,"machine learning"),(7,"scikit-learn"),(7,"Mahout"),(7,"neural networdks"),
             (8,"neural networdks"),(8,"deep learning"),(8,"Big Data"),
             (8,"artificial intelligence"),
             (9,"Hadoop"),(9,"Java"),(9,"MapReduce"),(9,"Big Data")]
# 找出有共同爱好的用户——需要遍历整个兴趣列表
def data_scientists_who_like(target_interest):
    return [user_id 
            for user_id, user_interest in interests 
            if user_interest == target_interest]
print(data_scientists_who_like('regression'))
# [3, 4] 说明用户3和4具有共同爱好‘regeression’
from collections import defaultdict
# 使用dict时,如果引用的Key不存在,就会抛出KeyError。如果希望key不存在时,返回一个默认值,就可以用defaultdict:
# 除了在Key不存在时返回默认值,defaultdict的其他行为跟dict是完全一样的。


# 得到关于每个interest的用户id,键是interest,值是带有这个interest的user_id列表
user_ids_by_interest = defaultdict(list)


for user_id, interest in interests:
    user_ids_by_interest[interest].append(user_id)
interests_by_user_id = defaultdict(list)


# 得到关于每个用户的interest,键是user_id,值是带有这个user_id的interest列表
for user_id, interest in interests:
    interests_by_user_id[user_id].append(interest)
def most_common_interests_with(user):
    return Counter(interested_user_id
                  for interest in interests_by_user_id[user['id']]
                  for interested_user_id in user_ids_by_interest[interest]
                  if interested_user_id != user['id'])
most_common_interests_with(users[0])
# Counter({1: 2, 5: 1, 8: 1, 9: 3}) 用户1与用户0有两个兴趣相同,用户9与用户0有三个兴趣相同

1.3.3 工资与工作年限
寻找工作年限和工资的关系

salaries_and_tenures = [(83000,8.7),(88000,8.1),(48000,0.7),(76000,6),(69000,6.5),
                        (76000,7.5),(60000,2.5),(83000,10),(48000,1.9),(63000,4.2)]
# 计算每个工作年限的薪水,键是year,值是对每一个tenure的salary列表
salary_by_tenure = defaultdict(list)


for salary, tenure in salaries_and_tenures:
    salary_by_tenure[tenure].append(salary)
    
# 计算每个工作年限的平均薪水,键是year,值是tenure相对应的平均salary
    average_salary_by_tenure = {
    tenure : sum(salaries) / len(salaries)
    for tenure, salaries in salary_by_tenure.items()
}
average_salary_by_tenure
# 因为上述数据中任意两个用户都没有相同的工作年限,所以均值结果作用有限,仅表示每个用户的独立收入
# 将用户工作年限分组
def tenure_bucket(tenure):
    if tenure < 2:
        return 'less than two years'
    elif tenure < 5:
        return 'between two and five years'
    else:
        return 'more than five years'
salary_by_tenure_bucket = defaultdict(list)

for salary, tenure in salaries_and_tenures:
    bucket = tenure_bucket(tenure)
    salary_by_tenure_bucket[bucket].append(salary)
    
# 计算每个工作年限的平均薪水,键是year,值是tenure相对应的平均salary
average_salary_by_bucket = {
    tenure_bucket : sum(salaries) / len(salaries)
    for tenure_bucket, salaries in salary_by_tenure_bucket.items()
}
average_salary_by_bucket
# {'between two and five years': 61500.0,
#  'less than two years': 48000.0,
#  'more than five years': 79166.66666666667}

1.3.4 付费账户
预测用户是否付费
years_paid = [(0.7, 'paid'),
              (1.9, 'unpaid'),
              (2.5, 'paid'),
              (4.2, 'unpaid'),
              (6, 'unpaid'),
              (6.5, 'unpaid'),
              (7.5, 'unpaid'),
              (8.1, 'unpaid'),
              (8.7, 'paid'),
              (10, 'paid'),]
# 预测是否付费
def predict_paid_or_unpaid(years_experience):
    if years_experience < 3.0:
        return 'paid'
    elif years_experience < 8.5:
        return 'unpaid'
    else:
        return 'paid'
predict_paid_or_unpaid(years_paid[1][0])
# 'paid'  year == 2.5 的预测结果为paid,实际上是unpaid

1.3.5 兴趣主题
提取interests内兴趣关键词
words_and_counts = Counter(word
                           for user, interest in interests
                           for word in interest.lower().split())
for word, count in words_and_counts.most_common():
    if count > 1:
        print(word, count)
learning 4
big 3
data 3
java 3
python 
machine 3
hadoop 2
hbase 2
cassandra 2
scikit-learn 2
r 2
statistics 2
regression 2
probability 2
neural 2
networdks 2

以上是Ch1的相关内容,第一次写博客,排版不好,请见谅
2018.01.30  YR

【高维统计N2】工具和方法 高维统计的工具和方法 阅读详情

相关推荐

图灵程序丛书 —《数据科学入门》— Ch4-Ch7 线性代数、统计学、概率、假设与推断

Ch4-Ch7 线性代数、统计学、概率、假设与推断此系列记录《数据科学入门》学习笔记Ch 4 线性代数4.1 向量# 向量加减法 def vector_add(v, m): return [v_i + w_i for v_i, w_i in zip(v, w)] def vector_subtract(v, m): return [v_i - w_i for v_i, w_i ...

NJYR21的博客 519

读书笔记数据科学入门————数据科学导论

问题1:从给定字典中寻找关键联系人 关系序列:friendships=[(0,1),(0,2),(1,2),(1,3),(2,3),(3,4),(4,5),(5,6),(5,7),(6,8),(7,8),(8,9)] 每个属性列表:users=[{"id":0,"name":"Hero"},{"id":1,"name":"Dunn"},{"id":2,"name":"Sue"},{"i

hhy518518的专栏 3551

UA MATH567 高维统计IV Lipschitz组合3 高斯分布的Lipschitz函数

UA MATH567 高维统计IV Lipschitz组合3 高斯分布的Lipschitz函数 首先我们在欧氏空间(Rn,B(Rn))(\mathbb{R}^n,\mathcal{B}(\mathbb{R}^n))(Rn,B(Rn))上建立高斯概率测度γn\gamma_nγn​,满足∀B∈B(Rn)\forall B \in \mathcal{B}(\mathbb{R}^n)∀B∈B(Rn), γn(B)=∫B1(2π)n/2e−∥x∥222dx\gamma_n(B) = \int_B \frac{1}{(

一个不愿透露姓名的博客 722

Python字典经典例题-key,value灵活运用

一、前言 今天朋友给我发来这样一道题,给定一个字典 d1 = {'李阳':['音乐','读书','跑步'], '王天薇':['美食','诗歌','旅游'], '郭晓强':['编程','骑行','旅游','跑步'], '文雨非':['羽毛球','跑步','音乐','诗歌'], '郑菲菲':['美食','排球','舞蹈']} 要求找出共同爱好的人,爱好作为新字典的key,姓名作为新字典的value 话不多说直接上代码 二、实现 new_dict =...

Ljj9889的博客 6515

Python数据挖掘之用图挖掘同样喜欢梅西的的人

前言: 本次同样在twitter上进行数据挖掘,主题是构建图,计算相似度,找到同样喜欢梅西的人,之后可以进行好友推荐,或者用户建群等。 编辑工具:anaconda 的jupyter notebook,所以会直接在代码后面跟上输出。 数据集:如果不想麻烦的弄数据的话,可以跳过下面获取数据步骤,直接使用文末数据,导入即可。 获取Twitter好友数据 写入授权令牌 import tw...

baoFeng_Li的博客 1415

实测对比:Gromacs GPU版vsCPU版性能差异到底有多大?2023最新基准测试

本文通过2023年最新基准测试,详细对比了Gromacs GPU版与CPU版的性能差异。测试显示,GPU版本在计算速度上可提升54倍,同时显著降低内存需求和能耗成本。文章还提供了GPU版安装优化实践和硬件选购指南,为计算生物学研究提供关键参考。

weixin_29243063的博客 327

【OR】Robust Optimization(8): Probability and tail bounds

Robust Optimization part VI

0x00 813

Linux下CUDA 11.8与vllm的完美搭配:从环境配置到避坑指南

本文详细介绍了在Linux系统中为CUDA 11.8环境部署vLLM的完整实战指南。针对cu118与vLLM的版本兼容性核心问题,提供了从Python、PyTorch版本选择,到关键依赖vllm-nccl-cu11的安装避坑,以及环境调优、生产级容器化部署的全面解决方案,帮助开发者高效构建稳定的大模型推理服务。

weixin_29095049的博客 308

图灵程序丛书 —《数据科学入门》— Ch2 Python 速成

Ch2 Python 速成此系列记录《数据科学入门》学习笔记2.1 基础内容2.1.3 空白形式python使用缩进的形式分隔代码块,可利用‘Tab’键快速找到键入位置。for i in [1, 2, 3, 4, 5]: print(i) for j in [1, 2, 3, 4, 5]: print(j) print(i + j) prin...

NJYR21的博客 443

激光定位算法竞技场:hdl_localization与Cartographer/AMCL的横向技术解剖

本文深入对比了hdl_localization、Cartographer和AMCL三种激光定位算法的技术原理与性能表现。通过UKF-NDT融合、图优化和粒子滤波等核心技术,分析了各算法在结构化环境、动态环境和大尺度场景下的适应性。实验数据表明,Cartographer在全局一致性上表现最优,而AMCL在动态环境中更具鲁棒性。文章还提供了算法选型指南和参数调优技巧,为工程实践提供参考。

weixin_29062865的博客 365

从零开始,用Cadence Virtuoso手把手仿真一个1.5V LDO(附完整电路与仿真脚本)

本文详细介绍了如何使用Cadence Virtuoso从零开始仿真一个1.5V LDO,包括环境准备、电路导入、Testbench构建、核心仿真类型分析以及高级调试技巧。通过完整的电路与仿真脚本,帮助读者掌握LDO设计与仿真的关键技术,提升电路设计能力。

weixin_31309419的博客 445

图灵程序丛书 —《数据科学入门》— Ch9-Ch10 获取数据、数据工作

Ch9-Ch10  获取数据、数据工作此系列记录《数据科学入门》学习笔记(停止)Chap 9 获取数据(只有9.2)9.2 读取文件9.2.1 文本文件基础# 'r'意味只读 file_for_reading = open('reading_file.txt', 'r') # 'r'意味写入,会破坏已存在的文件 file_for_writing = open('reading_file.txt'...

NJYR21的博客 589

路径搜索算法——RRT*算法

RRT算法是RRT算法的优化版本,通过引入路径优化机制实现渐进最优性。该算法在高维空间和复杂环境中表现优异,主要步骤包括随机采样、树扩展和邻近节点重新连接。相比RRT,RRT能够不断优化路径质量,但计算复杂度更高。Python实现展示了其核心逻辑:随机采样扩展树节点,检查碰撞,选择最优父节点,并通过重新连接优化路径。算法适用于机器人导航等场景,但需平衡计算效率与路径质量。

swaggytiger的博客 3061

图灵程序丛书 —《数据科学入门》— Ch8 梯度下降法

Ch8 梯度下降法此系列记录《数据科学入门》学习笔记8.2 梯度下降的思想梯度下降法只能找到局部最优解,而不是全局最优解;当有多个全局最优解时,可以通过多尝试一些初始点来重复搜索;当一个函数没有最小点时,计算可能会陷入死循环。8.2 估算梯度def sum_of_squares(v): return sum(v_i ** 2 for v_i in v) # 单变量函数的导数可通过差商来定...

NJYR21的博客 705

Android16 RK3576修改亮度调节为线性调节

文章摘要: 本文分析了Android系统中亮度调节的非线性问题,并提供了线性化改造方案。首先通过追踪Settings和SystemUI代码,发现亮度调节使用了BrightnessUtils类中的非线性Gamma空间转换算法。然后重点修改了BrightnessUtils类,将原有的Hybrid Log Gamma(HLG)算法替换为简单的线性映射公式。最后在自定义工具窗口中实现了基于系统标准接口的亮度调节功能,通过SeekBar的0-100%百分比值线性映射到1-255的系统亮度值。改造后的亮度调节更加直观,

tzj1058756809的博客 75

交换机四种光互联技术:OIO、OBO、NPO与CPO

在过去几十年里,数据中心交换机主要依赖电信号通过铜线进行数据传输。然而,随着数据传输速率从100Gbps向400Gbps、800Gbps甚至1.6Tbps迈进,传统电互联(Electrical Input & Output, EIO)面临三大瓶颈:信号衰减、功耗激增和空间限制。例如,高速信号在长距离铜线传输中会产生严重的信号失真,迫使设计者加入数字信号处理器(DSP)来补偿信号衰减,这进一步推高了功耗和成本。此外,传统可插拔光模块的体积较大,限制了端口密度,难以满足现代数据中心对高带宽密度的需求。

网络技术联盟站 3128

图灵程序丛书 —《数据科学入门》— Ch3 可视化数据(matplotlib)

Ch3 可视化数据此系列记录《数据科学入门》学习笔记3.1 matplotlib%matplotlib inline import matplotlib.pyplot as plt years = [1950, 1960, 1970, 1980, 1990, 2000, 2010] gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 149...

NJYR21的博客 538

基于深度学习的三维重建算法——详解与实现

随着深度学习技术的迅猛发展,基于深度学习的三维重建算法在最近几年取得了显著的进展。而基于深度学习的三维重建算法通过利用深度神经网络,能够从大规模数据中学习到更准确、鲁棒的三维结构表示。本文综述了基于深度学习的三维重建算法,并给出了相应的源代码。随着深度学习技术的不断发展,我们相信基于深度学习的三维重建算法将会在未来得到更广泛的应用。实验结果表明,基于深度学习的三维重建算法在准确性和鲁棒性方面取得了显著的提升。以上是关于基于深度学习的三维重建算法的详细介绍与实现,希望对您有所帮助。

CyberGenius的博客 1227

Python3 小技巧—— sorted(t, key = lambda _: _[0])用法

今天在看 Eric Matthes 的《Python编程从入门到实践》中看到sorted的一种特殊用法,这里记录下。

小火柴棒的博客 1万+

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

统计学——基于R(第3版)(基于R应用的统计学丛书)作者:贾俊平 习题答案 第四章

load("C:/exercise/ch4/exercise4_1.RData") exercise4_1 #4.1 sum(0.209,0.223,0.178,0.114) sum(0.041,0.130) sum(0.061,0.028,0.011,0.004,0.001) #4.2 #(1) dbinom(2,4,0.1) #(2) pbinom(1,4,0.1) #4.3 ...

qq_45083698的博客 5049

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

图灵数学·统计学系列

Turing Mathematics Statistics(TMS)系列 ---------------------------------------------- 图灵数学·统计学系列 ---------------------------------------------- 53 书名: 应用随机过程:概率模型导论(第10版) 书号: 978-7-115-25031-5 原书名

wilim 6963

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

对我启发最大的数学学习方法(转自知乎)

数学方面的能力该怎么培养数学系博士怒答!我想大家都有这样的体会:小学的时候你根本不知道初中数学是什么样,高中的时候你也根本想不到大学数学是什么样。而大学生,如果你不专注于数学,恐怕也不知道现代数学是什么模样。下面将分别从学数学的动机、数学不同学科的分类以及如何切实可行培养数学能力等几个方面阐述如何学习数学。(另外,欢迎大家收看在数学系读书的感受如何?体会一下数学的乐趣,数学系人的特点以及智商不够该...

weixin_30292745的博客 513

日志客户端(Logstash,Fluentd, Logtail)横评

日志客户端(Logstash,Fluentd, Logtail)横评 https://yq.aliyun.com/articles/3228 Python的GIL是什么鬼,多线程性能究竟如何 http://cenalulu.github.io/python/gil-in-python/ Ruby 无人知晓的 GIL https://ruby-china.org/topics/28415 ...

yb223731的博客 4971

陶哲轩告诉我们数学学习方法

在大二下学期我翻译了著名数学家陶哲轩的一部分博文,现在把它贴到下面,希望对读者有所启发. 不要害怕学习其它领域的知识 译自Don't be afraid to learn things outside your field . 尽可能地了解全局,同时精通局部.(赫胥黎) 数学恐惧症普遍存在于较广泛的群体中.不幸的是,它有时也存在于职业数学...

weixin_34205076的博客 318

图灵书单——程序员的算法

小编跟着图灵听课去(4月)参加了很多线下的会议,再次深深体会到算法很重要,因为不管是什么技术主题的大会,人们都会找算法的书。现在小编就来盘点一下图灵新出版的算法书,推荐给大家。1、《程序员的数学》第3弹——线性代数作者:[日] 平岡和幸,[日] 堀玄译者:卢晓南定价:79页数:384● 机器学习、数据挖掘、模式识别必备基础知识● 从入门到应用,透彻理解线性代数的本质《程序员的数学3:线性代数》沿袭“

图灵教育 7012
下一篇: 图灵程序丛书 —《数据科学入门》— Ch2 Python 速成
NJYR21
博客等级 码龄9年 78粉丝 38原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值