tensorflow

Vectorized creation of an array of diagonal square arrays from a liner array in Numpy or Tensorflow

佐手、 提交于 2020-11-28 09:19:08
问题 I have an array of shape [batch_size, N] , for example: [[1 2] [3 4] [5 6]] and I need to create a 3 indices array with shape [batch_size, N, N] where for every batch I have a N x N diagonal matrix, where diagonals are taken by the corresponding batch element, for example in this case, In this simple case, the result I am looking for is: [ [[1,0],[0,2]], [[3,0],[0,4]], [[5,0],[0,6]], ] How can I make this operation without for loops and exploting vectorization? I guess it is an extension of

关于mnist数据集下载的相关问题

生来就可爱ヽ(ⅴ<●) 提交于 2020-11-27 10:51:59
文章目录 问题描述:在Tensorflow 2.0.1版本中下载mnist数据集 原因分析: 解决方案: 问题描述:在Tensorflow 2.0.1版本中下载mnist数据集 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets(“MNIST_data”, one_hot=True) 输入上述代码后,会出现如下错误: 原因分析: 主要原因是下载地址是外国网站,网络一直无法下载成功。 可以将input_data里的url改成 我上述的url(上面注释的一行本来是Source_url,博主这边把它注释掉了) 解决方案: 手动下载地址:http://yann.lecun.com/exdb/mnist/ 下载这4个文件,注意不需要解压!!! 将下载的4个文件放入到你.py的文件目录下(也就是放在你项目的目录下) 然后将代码:mnist = input_data.read_data_sets(“MNIST_data”, one_hot=True) 修改为:mnist = input_data.read_data_sets("./", one_hot=True) 这样问题就解决了,代码可以正常运行,mnist数据集可以正常使用了。

torch same padding

醉酒当歌 提交于 2020-11-27 09:04:38
CNN中,增加Padding过后,为我们带来的那些负面影响。 如上图所示: 第一行为普通3x3卷积,步长1,padding 0, 第二行为普通3x3卷积,步长1,padding 1, 第三行为膨胀3x3卷积,dilation rate=3,步长1,padding 3. 上图箭头右向所指,为cnn底层在caffe 和darknet的底层实现,用c或c++,至于pytorch和tensorflow 是否也是这样实现cnn我不清楚,但是目前来讲,有效实现卷积的也就3种方式, im2col(上图) ,winograd, FFT,但是还是im2col比较常见,winograd好像是商汤最近几年提出来的,通过特殊数学计算方式,减少计算量,目前该方法被应用在腾讯移动端深度学习框架NCNN中,至于FFT,还没见到用在深度学习种。 至于为什么使用im2col,这还是贾清扬大神在写caffe时提出来的,因为图像中,一个块内的像素点在内存中是地址不连续的,所以对于同一个块内的像素想要缓存到cache上,可能出现多次内存访问,效率极低,所以设计出im2co方式,提前将需要计算的像素点放在连续地址上。 因此,对于同一图像,除了原始图像在内存中占空间,使用im2col又会消耗另一份空间。 如上图所示,对于8x8的图像: 不加padding,计算量为9x36=324, 内存消耗为8x8=64,有效内存为64

window10+Anaconda3-4.2+python3.5+Pycharm+清华镜像源安装

北城以北 提交于 2020-11-27 05:25:32
window下对python3.5适用性比较好,Anaconda4.2里面包含了python3.5。 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/清华镜像源下载 http://blog.csdn.net/u012513525/article/details/54947398 (pycharm配置清华镜像源) http://blog.csdn.net/u012318074/article/details/78844789 (anaconda的navigator闪退问题的解决) http://blog.csdn.net/hola_f/article/details/70482300 http://blog.csdn.net/u013080652/article/details/68922702 https://jingyan.baidu.com/article/1876c8527be1c3890a137645.html http://python.jobbole.com/86236/ window10中tensorflow的安装步骤: 第一步:安装anconda3-4.2 ,因为自带python3.5,对windows比较友好。 这一步安装直接按照next即可。 第二步:安装tensorflow

刚刚公布!一个关于假期调整的大好消息

a 夏天 提交于 2020-11-27 05:24:08
看到这个消息后,第一时间播放一个好消息,忍不住激动了一下,哈哈。 两会期间,有代表提出今年五一假期只放1天假。总理回应说,会让有关部门抓紧研究。结果今天就落实了。 国务院办公厅关于 调整2019年劳动节假期安排 的通知 2019年5月1日至4日放假调休, 共4天 。 4月28日(星期日)、5月5日(星期日)上班。 大家看到后,一定很开心吧。 -更多分类精选文章- 干货资料汇总 | 程序员必知算法 | AI入门 | 吴恩达机器学习入门视频 | Kaggle最受欢迎的10个数据集下载 | 玩转Pandas系列 | 概率论、线性代数、凸优化极简入门 | 算法图解高清电子版下载 | Data Analysis 高清电子版下载 | TensorFlow 彩图下载 | Python数据科学手册高清版下载 | 最专业的简历模板 一个用心的公众号 本文分享自微信公众号 - Python与算法社区(alg-channel)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/4585819/blog/4583464

When is TensorFlow's ParameterServerStrategy preferable to its MultiWorkerMirroredStrategy?

家住魔仙堡 提交于 2020-11-27 04:27:05
问题 When training a neural network across multiple servers and GPUs, I can't think of a scenario where the ParameterServerStrategy would be preferable to the MultiWorkerMirroredStrategy . What are the ParameterServerStrategy 's main use cases and why would it be better than using MultiWorkerMirroredStrategy ? 回答1: MultiWorkerMirroredStrategy is intended for synchronous distributed training across multiple workers, each of which can have multiple GPUs ParameterServerStrategy : Supports parameter

深度学习的中文资源,教程推荐!

假如想象 提交于 2020-11-25 08:33:30
教材,教程,中文的,直对问题回答一波: 注意:我认为教程不在多,在于精,网上很多教程,但下面我整理一份我认为比较靠谱的中文机器学习和深度学习基础教程。在学习基础的同时,应该要学好英语! python零基础开始,推荐廖雪峰python教程 ,2,3自选 1 机器学习: 《机器学习实战》入门必备,不难,容易上手,而且可以增加兴趣,缺点:理论不够深入 《机器学习》西瓜书,《统计学习方法》理论上的经典,理论详细又深入,真的值得一看。缺点:有点枯燥,建议结合机器学习实战。 2 深度学习框架和库(撸起代码来): 先来代码,我始终觉得,若理论很枯燥,那先用代码来提提兴趣。 TensorFlow 官方文档中文版 ,官方的,靠谱!tensorflow神器,绝对要有啊! 机器学习系列 | 莫烦Python ,再次推荐莫凡教程,这里有很多教程,推荐其中的numpy,pytorch教程。优点:简单,易懂,推荐pytorch好好学,比tensorflow灵活,个人感觉。缺点:有些过于简单。 3 深度学习: 吴恩达的deeplearning.ai,这个在网易云课堂有中文字幕版的-- 链接 。这个入门深度学习可以有。吴老师的课,通俗,易懂,最重要的:可靠 经典的cs231n,官网 链接 ,cs231n是有笔记的- 链接 ,当然,知乎上的一些大神对这个笔记进行了翻译--- 链接 。如果看英文很吃力,参考这个翻译

How can I modifya sequencial data using map or filter or reduce method for tf.data.Dataset objects?

牧云@^-^@ 提交于 2020-11-25 04:05:20
问题 I have a python data generator- import numpy as np import tensorflow as tf vocab_size = 5 def create_generator(): 'generates sequences of varying lengths(5 to 7) with random number from 0 to voca_size-1' count = 0 while count < 5: sequence_len = np.random.randint(5, 8) # length varies from 5 to 7 seq = np.random.randint(0, vocab_size, (sequence_len)) yield seq count +=1 gen = tf.data.Dataset.from_generator(create_generator, args=[], output_types=tf.int32, output_shapes = (None, ), ) for g in

can we show underfitting with mobilenet?

时间秒杀一切 提交于 2020-11-25 03:33:28
问题 Are there any examples which could prove/demonstrate that we can see underfitting while classifying images with mobilenet too? I have tried transfer learning and feature extraction with mobilenet in ml5.js Since it's already trained on several thousand images, even when I add and train only 3 new images, I seem to get correct results. I am looking for an example such that I can demonstrate to the user that underfitting is possible with mobilenet as well. It could be by changing a particular

pip install tensorflow cannot find file called client_load_reporting_filter.h

*爱你&永不变心* 提交于 2020-11-25 03:33:10
问题 I keep failing to run pip install on the tensorflow package. First it downloads the .whl file, then goes through a bunch of already satisfied requirements until it gets to installing collected packages: tensorflow , at which point here's the error I get: ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Borik\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site