我试图理解张量流中seq2seq.py中定义的seq2seq模型.我使用了我从tensorflow附带的translate.py示例中复制的一些代码.我一直得到同样的错误,真的不明白它来自哪里.
重现错误的最小代码示例:
import tensorflow as tf
from tensorflow.models.rnn import rnn_cell
from tensorflow.models.rnn import seq2seq
encoder_inputs = []
decoder_inputs = []
for i in xrange(350):
encoder_inputs.append(tf.placeholder(tf.int32, shape=[None],
name="encoder{0}".format(i)))
for i in xrange(45):
decoder_inputs.append(tf.placeholder(tf.int32, shape=[None],
name="decoder{0}".format(i)))
model = seq2seq.basic_rnn_seq2seq(encoder_inputs,
decoder_inputs,rnn_cell.BasicLSTMCell(512))
Run Code Online (Sandbox Code Playgroud)
我在评估最后一行时得到的错误(我在python解释器中以交互方式评估它):
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/py1053173el", line 12, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/models/rnn/seq2seq.py", line 82, in basic_rnn_seq2seq
_, enc_states = rnn.rnn(cell, encoder_inputs, dtype=dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/models/rnn/rnn.py", line 85, in rnn
output_state = cell(input_, state)
File …Run Code Online (Sandbox Code Playgroud) python machine-learning neural-network deep-learning tensorflow
是否有可能在Xgboost中训练具有多个连续输出的模型(多元回归)?培养这种模型的目标是什么?
在此先感谢您的任何建议
我正在学习下班后学习clojure的过程中,我正在通过制作一个小游戏(喜欢quil库)让我熟悉特定和一般FP中的clojure的不同方面.
因此,我的游戏世界存在地图数据结构的三维网格(矢量地图矢量的矢量).我想迭代3d空间中的每个点(map)并在满足条件时更改数据.这是我最初的解决方案:
(游戏数据结构是游戏状态(地图))
(defn soil-gen [game]
(let [world-x (game :world-x)
world-y (game :world-y)
world-z (game :world-z)]
(for [x (range world-x)
y (range world-y)
z (range world-z)
:when (> z (* world-z (rand)))]
(assoc-in game [:world x y z :type] :soil))))
Run Code Online (Sandbox Code Playgroud)
但是这会返回每次迭代的结果列表(我的游戏状态数据结构)而不是一个游戏数据结构.我应该能够以某种方式将每次迭代的结果传递回去.像loop/recur这样的东西可能但是我认为你不能将recur与for结合起来.
有人知道吗?
谢谢
我想知道在clojure中最常用的方法是将嵌套映射转换为嵌套向量.
例如来自:
{:left {:left {:left 1, :right 5, :middle 1, :score 10}, :right {:left 7, :right 8, :middle 7, :score 0}, :middle 5, :score 10}, :right 9, :middle 8, :score 10}
Run Code Online (Sandbox Code Playgroud)
至:
[ [ [ 1, 5, 1, 10 ], [ 7, 8, 7, 0], 5, 10], 9, 8, 10]
Run Code Online (Sandbox Code Playgroud)
非常感谢
assoc-in可以更改矢量/贴图中索引/键的值.在地图中,如果某个键不存在,则它会生成一个新的键/值对.是否存在类似于向量的内容(如果索引不存在,则在该索引处生成具有该值的列表)类似于:
(reduce (fn [g [x y]] (assoc-in g [x y] y ))
[]
(for [x (range 2)
y (range 2)]
[x y]))
Run Code Online (Sandbox Code Playgroud)
上面的代码生成:
[{1 1, 0 0} {1 1, 0 0}]
Run Code Online (Sandbox Code Playgroud)
我希望它生成:
[[0 1] [0 1]]
Run Code Online (Sandbox Code Playgroud)
这有可能以一种简单的方式吗?
谢谢
编辑:更清楚,我只是想让它生成嵌套向量而不是嵌套映射(或映射向量)现在我把y作为值,但这只是一个例子.
我知道我可以用循环和重复来解决我的问题,但它似乎是一个简单的(常见的?)操作,我想知道在clojure中没有单个函数或者更简洁的方法然后循环/重复来解决这个问题.我搜索了它但却找不到东西.
我正在寻找的功能如下.
(the-function n input some-function)
Run Code Online (Sandbox Code Playgroud)
其中n是在输入上重新调用some-function的时间.
一个简单的例子是:
(the-function 3 1 (fn [x] (+ x 1)))
=> 4
Run Code Online (Sandbox Code Playgroud)
在Clojure中有类似的东西吗?
最好的祝福
我需要从获得一个随机值vector的integers.
我还需要在vector没有值键的情况下取回.
示例代码如下.我知道我可以轻松地将此代码放入function重用中.
但是想知道是否有一些功能或更好的方法来创建一个vector没有第n个元素的新东西?(因此是function核心clojure 中第(n)个的补充)
(let [ vector [1 2 3 5 9 1]
id (rand-int (count vector))
value (nth vector id)
head (take id vector)
tail (drop (+ id 1) vector)
vector (flatten [head tail])]
{:value value :new-vector vector})
Run Code Online (Sandbox Code Playgroud)