tensorflow

Tensorflow-IO Dataset input pipeline with very large HDF5 files

佐手、 提交于 2021-02-10 12:18:10
问题 I have very big training (30Gb) files. Since all the data does not fit in my available RAM, I want to read the data by batch. I saw that there is Tensorflow-io package which implemented a way to read HDF5 into Tensorflow this way thanks to the function tfio.IODataset.from_hdf5() Then, since tf.keras.model.fit() takes a tf.data.Dataset as input containing both samples and targets, I need to zip my X and Y together and then use .batch and .prefetch to load in memory just the necessary data. For

TensorFlow function to check whether a value is in given range?

ε祈祈猫儿з 提交于 2021-02-10 12:14:41
问题 I know there is tf.greater(x,y) which will return true if x > y (element-wise). Is there a function that returns true if lower_bound < x < upper_bound (element-wise) for a tensor x? 回答1: There's not a specific function for that, but you can use a combination of tf.greater , tf.less , and tf.logical_and to get the same result. lower_tensor = tf.greater(x, lower) upper_tensor = tf.less(x, upper) in_range = tf.logical_and(lower_tensor, upper_tensor) 来源: https://stackoverflow.com/questions

TensorFlow function to check whether a value is in given range?

丶灬走出姿态 提交于 2021-02-10 12:14:30
问题 I know there is tf.greater(x,y) which will return true if x > y (element-wise). Is there a function that returns true if lower_bound < x < upper_bound (element-wise) for a tensor x? 回答1: There's not a specific function for that, but you can use a combination of tf.greater , tf.less , and tf.logical_and to get the same result. lower_tensor = tf.greater(x, lower) upper_tensor = tf.less(x, upper) in_range = tf.logical_and(lower_tensor, upper_tensor) 来源: https://stackoverflow.com/questions

How can we use lbfgs_minimize in TensorFlow 2.0

馋奶兔 提交于 2021-02-10 12:00:33
问题 I have been unable to reproduce this example from tensorflow having tensorflow 2.0 installed. This is the original snippet: # A high-dimensional quadratic bowl. ndims = 60 minimum = np.ones([ndims], dtype='float64') scales = np.arange(ndims, dtype='float64') + 1.0 # The objective function and the gradient. def quadratic(x): value = tf.reduce_sum(scales * (x - minimum) ** 2) return value, tf.gradients(value, x)[0] start = np.arange(ndims, 0, -1, dtype='float64') optim_results = tfp.optimizer

How can we use lbfgs_minimize in TensorFlow 2.0

余生长醉 提交于 2021-02-10 11:58:16
问题 I have been unable to reproduce this example from tensorflow having tensorflow 2.0 installed. This is the original snippet: # A high-dimensional quadratic bowl. ndims = 60 minimum = np.ones([ndims], dtype='float64') scales = np.arange(ndims, dtype='float64') + 1.0 # The objective function and the gradient. def quadratic(x): value = tf.reduce_sum(scales * (x - minimum) ** 2) return value, tf.gradients(value, x)[0] start = np.arange(ndims, 0, -1, dtype='float64') optim_results = tfp.optimizer

用 tensorflow实现DeepFM

删除回忆录丶 提交于 2021-02-10 11:27:21
http://www.fabwrite.com/deepfm 文章 DeepFM: A Factorization-Machine based Neural Network for CTR Prediction 介绍了一种深度学习模型,以实现点击率预估。用 tensorflow 试着写了 DeepFM,见 https://github.com/zgw21cn/DeepFM 。 1. FNN、PNN、wide&deep等此前几种深度模型 见下图。 (1) FNN,见图左边。用 FM 预训练embedding layer,然后DNN训练。作者认为有两点局限:embedding layer 的参数会受到 FM 的影响;预训练计算量大,效率问题。同时 FNN仅能捕捉高阶特征,相比之下,DeepFM 无需预训练,且能捕捉高阶和低阶特征。 (2) PNN,见图中间。为了捕捉高阶特征间的组合作用,PNN在 embedding layer 和首层 hidden layer 间引入了 product layer。根据 product 类型的不同,有多种类型的 product layer。product 类型有内积、外积、内积和外积的混合。 PNN的局限在于,外积由于是近似计算会丢失信息而比内积不可靠;内积更可靠,但是仍会计算量大。类似于 FNN,PNN忽略了低阶特征。 (3) Wide&Deep

毕业设计之「神经网络与深度学习概述」 (一)

ε祈祈猫儿з 提交于 2021-02-10 09:31:53
阅读本文大概需要 18 分钟。 前言 本章节属于我 毕业设计系列推文 中的基础篇内容,是对 神经网络与深度学习基础 的一个概述,共包括两节内容(分别是毕业设计之「神经网络与深度学习概述」 (一)和 毕业设计之「神经网络与深度学习概述」(二) ),我会分成两次推文进行推送,本文是「神经网络与深度学习概述」的第一篇,主要内容将围绕 神经网络的基础 进行展开。 需要注意的一点,由于本小节推文中涉及较多的公式、特殊符号、表格等,从而造成在排版上有较大难度,因此我以截图的形式进行本次推文的推送,各位读者请见谅。 神经网络基础 - End - 往期推荐 🔗 近期推文 TensorFlow 2.0 概述 毕业设计之「神经网络与深度学习概述」(二) 毕业设计之「测试实验及结果分析」(二) 微信拍一拍效果的原理分析及代码实现 Python 开发植物大战僵尸游戏 数据结构与算法系列 数据结构与算法-1 :旋转图像 数据结构与算法 -2 :罗马数字与整数的相互转换 数据结构与算法 -3 :复原IP地址 数据结构与算法 -4、5 :两数相加&&两数之和 毕业设计系列 TensorFlow环境搭建 毕业设计(基于TensorFlow的深度学习与研究)之文献翻译篇 TensorFlow 2.0 概述 毕业设计(基于TensorFlow的深度学习与研究)之核心篇CNN-AlexNet详解 毕业设计之

How to get/set weights for a supervised model in tensorflow.js?

混江龙づ霸主 提交于 2021-02-10 07:53:15
问题 I'd like to change the weights of a supervised model but I get the same exact result after changing the weights. What am I doing wrong? const model = tf.sequential(); model.add(tf.layers.dense({...})); model.add(tf.layers.dense({...})); model.add(tf.layers.dense({...})); model.compile({...}); model.fit({}); const result1 = model.predict(tf.tensor2d(...)).dataSync(); const newWeights = []; model.layers.map((layer, i) => { newWeights[i] = [] const weights = layer.getWeights(); newWeights[i][0]

How can I use GPU for running a tflite model (*.tflite) using tf.lite.Interpreter (in python)?

大城市里の小女人 提交于 2021-02-10 07:25:36
问题 I have converted a tensorflow inference graph to tflite model file (*.tflite), according to instructions from https://www.tensorflow.org/lite/convert. I tested the tflite model on my GPU server, which has 4 Nvidia TITAN GPUs. I used the tf.lite.Interpreter to load and run tflite model file. It works as the former tensorflow graph, however, the problem is that the inference became too slow. When I checked out the reason, I found that the GPU utilization is simply 0% when tf.lite.Interpreter is

hickle NameError: name 'file' is not defined

柔情痞子 提交于 2021-02-10 07:25:29
问题 please explain to me why this error getting for me. I have install python 3.5 in ubuntu import os import hickle as hkl import numpy as np array_obj = np.ones(32768, dtype='float32') hkl.dump(array_obj, 'test.hkl', mode='w') the result is Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\hickle.py", line 308, in dump h5f = file_opener(file_obj, mode, track_times) File "C:\Users\Admin\AppData