标签: machine-learning

如何将Tensorflow张量尺寸(形状)作为int值?

假设我有一个Tensorflow张量.如何将张量的尺寸(形状)作为整数值?我知道有两种方法,tensor.get_shape()以及tf.shape(tensor),但我不能让形状值作为整int32数值.

例如,下面我创建了一个二维张量,我需要得到行数和列数,int32以便我可以调用reshape()以创建一个形状的张量(num_rows * num_cols, 1).但是,该方法tensor.get_shape()返回值作为Dimension类型,而不是int32.

import tensorflow as tf
import numpy as np

sess = tf.Session()    
tensor = tf.convert_to_tensor(np.array([[1001,1002,1003],[3,4,5]]), dtype=tf.float32)

sess.run(tensor)    
# array([[ 1001.,  1002.,  1003.],
#        [    3.,     4.,     5.]], dtype=float32)

tensor_shape = tensor.get_shape()    
tensor_shape
# TensorShape([Dimension(2), Dimension(3)])    
print tensor_shape    
# (2, 3)

num_rows = tensor_shape[0] # ???
num_cols = tensor_shape[1] # ???

tensor2 = tf.reshape(tensor, (num_rows*num_cols, 1))    
# Traceback (most …
Run Code Online (Sandbox Code Playgroud)

python artificial-intelligence machine-learning tensorflow

70
推荐指数
4
解决办法
9万
查看次数

谁能解释一下StandardScaler?

我无法理解网页StandardScaler的文档中sklearn.

有人能用简单的语言向我解释一下吗?

python scaling machine-learning standardized scikit-learn

70
推荐指数
7
解决办法
9万
查看次数

当我们可以解析地解决线性回归时,为什么梯度下降

在线性回归空间中使用Gradient Descent有什么好处?看起来我们可以通过分析方法解决问题(找到最小成本函数的θ0-n),那么为什么我们仍然希望使用梯度下降来做同样的事情呢?谢谢

machine-learning linear-regression gradient-descent

69
推荐指数
3
解决办法
2万
查看次数

如何更新神经网络反向传播中的偏差?

有人可以向我解释如何在整个反向传播中更新偏见吗?

我读了不少书,但找不到偏见更新!

我知道偏差是1的额外输入,附加了一个重量(对于每个神经元).必须有一个公式.

谢谢,

@msw

最有趣的.谢谢,我认为有两个好点:1."如果省略偏差项,多层感知器的"通用近似"属性与最常用的隐藏层激活函数不成立.但Hornik(1993)证明了没有偏差的通用逼近性质的充分条件是激活函数的衍生物在原点处没有消失,这意味着利用通常的S形激活函数,可以使用固定的非零偏置项代替可训练的偏差.2.偏差项可以像其他权重一样学习."所以我要么增加'恒定权重',要么像所有其他权重一样使用梯度下降训练这个权重.

我理解对吗?

math artificial-intelligence machine-learning neural-network

68
推荐指数
2
解决办法
5万
查看次数

提高朴素贝叶斯分类器准确性的方法?

我使用Naive Bayes分类器将数千个文档分类为30个不同的类别.我已经实现了Naive Bayes分类器,并且通过一些特征选择(主要是过滤无用的单词),我获得了大约30%的测试精度,45%的训练准确度.这明显优于随机,但我希望它更好.

我尝试用NB实现AdaBoost,但它似乎没有给出明显更好的结果(文献似乎对此有所分歧,一些论文称AdaBoost与NB没有给出更好的结果,其他人这样做).你知道NB的任何其他扩展可能会提供更好的准确性吗?

machine-learning naivebayes

65
推荐指数
2
解决办法
4万
查看次数

值迭代和策略迭代之间有什么区别?

在强化学习中,策略迭代值迭代之间有什么区别?

根据我的理解,在价值迭代中,您使用Bellman方程来求解最优策略,而在策略迭代中,您随机选择策略π,并找到该策略的奖励.

我怀疑的是,如果你在PI中选择随机策略π,即使我们选择了几个随机策略,它如何保证成为最优策略.

machine-learning reinforcement-learning markov-models value-iteration

65
推荐指数
3
解决办法
4万
查看次数

如何获得scikit-learn分类器的最丰富的功能?

liblinear和nltk等机器学习包中的分类器提供了一种方法show_most_informative_features(),它对调试功能非常有用:

viagra = None          ok : spam     =      4.5 : 1.0
hello = True           ok : spam     =      4.5 : 1.0
hello = None           spam : ok     =      3.3 : 1.0
viagra = True          spam : ok     =      3.3 : 1.0
casino = True          spam : ok     =      2.0 : 1.0
casino = None          ok : spam     =      1.5 : 1.0
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果在scikit-learn中为分类器实现类似的东西.我搜索了文档,但找不到类似的东西.

如果还没有这样的功能,有人知道如何获得这些值吗?

非常感谢!

python classification machine-learning scikit-learn

64
推荐指数
5
解决办法
5万
查看次数

为什么F-Measure是一个调和均值而不是精确和召回措施的算术平均值?

当我们计算考虑精度和召回的F-测量时,我们采用两个测量的调和平均值而不是简单的算术平均值.

采用调和均值而不是简单平均值的直观原因是什么?

classification machine-learning data-mining

64
推荐指数
5
解决办法
1万
查看次数

如何解释张量流中的Poolallocator消息?

在训练tensorflow seq2seq模型时,我看到以下消息:

W tensorflow/core/common_runtime/gpu/pool_allocator.cc:227] PoolAllocator: After 27282 get requests, put_count=9311 evicted_count=1000 eviction_rate=0.1074 and unsatisfied allocation rate=0.699032
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:239] Raising pool_size_limit_ from 100 to 110
W tensorflow/core/common_runtime/gpu/pool_allocator.cc:227] PoolAllocator: After 13715 get requests, put_count=14458 evicted_count=10000 eviction_rate=0.691659 and unsatisfied allocation rate=0.675684
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:239] Raising pool_size_limit_ from 110 to 121
W tensorflow/core/common_runtime/gpu/pool_allocator.cc:227] PoolAllocator: After 6965 get requests, put_count=6813 evicted_count=5000 eviction_rate=0.733891 and unsatisfied allocation rate=0.741421
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:239] Raising pool_size_limit_ from 133 to 146
W tensorflow/core/common_runtime/gpu/pool_allocator.cc:227] PoolAllocator: After 44 get requests, put_count=9058 evicted_count=9000 eviction_rate=0.993597 and unsatisfied …

machine-learning tensorflow

64
推荐指数
1
解决办法
2万
查看次数

Tensorflow One Hot Encoder?

tensorflow是否有类似于scikit learn的用于处理分类数据的热门编码器?使用tf.string的占位符会表现为分类数据吗?

我意识到我可以在将数据发送到tensorflow之前手动预处理数据,但内置数据非常方便.

python machine-learning neural-network tensorflow

63
推荐指数
5
解决办法
7万
查看次数