
tensorflow2.0
luoganttcc
微信:luogantt2
展开
-
tf.reduce_sum 用法
import tensorflow as tf # x has a shape of (2, 3) (two rows and three columns): x = tf.constant([[1, 1, 1], [1, 1, 1]]) x.numpy() array([[1, 1, 1], [1, 1, 1]], dtype=int32) # sum all the elements # 1 + 1 + 1 + 1 + 1+ 1 = 6 tf.reduce_sum(x).numpy()原创 2020-10-15 20:24:59 · 329 阅读 · 0 评论 -
embedding 层的详细解释
原文链接 在这篇文章中,我们将介绍keras的嵌入层。为此,我创建了一个仅包含3个文档的样本语料库,这足以解释keras嵌入层的工作。 词嵌入在各种机器学习应用程序中很有用在开始之前,让我们浏览一下词嵌入的一些应用: 第一个吸引我的应用程序是在基于协同过滤的推荐系统中,我们必须通过分解包含用户项等级的效用矩阵来创建用户嵌入和电影嵌入。 要查看有关在Keras中使用词嵌入的基于CF推荐系统的完整教程,可以遵循我的这篇文章。 第二种用途是在自然语言处理及其相关应用程序中,我们必须为语料库文档中存在的所有翻译 2020-10-10 18:52:46 · 2028 阅读 · 0 评论 -
保存mnist到mongodb
import numpy as np from pymongo import MongoClient import tensorflow as tf import pandas as pd client=MongoClient('localhost',27017) db=client.mnist.data def save_mnist_mongodb(): (x, y), _ = tf....原创 2019-06-24 10:33:10 · 208 阅读 · 0 评论 -
tensorflow2.0 mnist
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 22 18:55:41 2019 @author: lg """ import tensorflow as tf def prepare_mnist_features_and_labels(x, y): x = tf.cast(x, tf.float3...原创 2019-06-24 10:34:35 · 1501 阅读 · 1 评论 -
tensorflow2.0 与tensorflow1.0的性能区别
从某种意义讲,tensorflow这个项目已经失败了,要不了几年以后,江湖上再无tensorflow 因为tensorflow2.0 和tensorflow1.0 从本质上讲就是两个项目,1.0的静态图有他的优势,比如性能方面,但是debug不方便,2.0的动态图就是在模仿pytorch,但是画虎不成反类犬. 为了对比1.0 与2.0 pip install tensorflow==2.0.0...原创 2019-06-24 17:21:13 · 27734 阅读 · 9 评论