运行以下内容:
virtualenv -p python3 venv
得到:
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /specific/a/home/cc/students/csguests/taivanbatb/venv/bin/python3
Also creating executable in /specific/a/home/cc/students/csguests/taivanbatb/venv/bin/python
Installing setuptools, pip, wheel...
Run Code Online (Sandbox Code Playgroud)
这是卡住的地方.
调用CTRL-C给出:
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 671, in main
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2328, in <module>
raise SystemExit(popen.wait())
File "/usr/lib/python2.7/subprocess.py", line 1376, in wait
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
File "/usr/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
return func(*args)
KeyboardInterrupt
main()
File …Run Code Online (Sandbox Code Playgroud) 我用动态形状的Tensor喂食:
x = tf.placeholder(tf.int32, shape=[None, vector_size])
我需要把它变成一个有shape=[1, vector_size]使用的张量列表x_list = tf.unpack(x, 0)
但它提出了一个ValueError因为第一维的长度是未知的,即它是None.
我一直试图通过使用另一个tf.placeholder动态提供形状来绕过这个,x但参数shape不能是Tensor.
我怎样才能tf.unpack()在这种情况下使用?
或者是否还有另一个函数可以将我输入的变量转换为张量列表?
提前致谢.
当我运行此代码时:
x = tf.placeholder(tf.int32, shape=(None, 3))
with tf.Session() as sess:
feed_dict = dict()
feed_dict[x] = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
input = sess.run([x], feed_dict=feed_dict)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Placeholder_2:0 is both fed and fetched.
我不确定我在这里做错了什么.为什么这不起作用?
我正在完成Udacity深度学习课程的作业6.我不确定为什么在这些步骤中使用zip()函数来应用渐变.
这是相关代码:
# define the loss function
logits = tf.nn.xw_plus_b(tf.concat(0, outputs), w, b)
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, tf.concat(0, train_labels)))
# Optimizer.
global_step = tf.Variable(0)
#staircase=True means that the learning_rate updates at discrete time steps
learning_rate = tf.train.exponential_decay(10.0, global_step, 5000, 0.1, staircase=True)
optimizer = tf.train.GradientDescentOptimizer(learning_rate)
gradients, v = zip(*optimizer.compute_gradients(loss))
gradients, _ = tf.clip_by_global_norm(gradients, 1.25)
optimizer = optimizer.apply_gradients(zip(gradients, v), global_step=global_step)
Run Code Online (Sandbox Code Playgroud)
应用该zip()功能的目的是什么?
为什么gradients和v存储呀?我以为zip(*iterable)只返回一个zip对象.
我试图找出应用于列表的操作.我有列表/数组名称预测,并执行以下一组指令.
predictions[predictions < 1e-10] = 1e-10
Run Code Online (Sandbox Code Playgroud)
此代码段来自使用Numpy的Udacity Machine Learning分配.
它以下列方式使用:
def logprob(predictions, labels):
"""Log-probability of the true labels in a predicted batch."""
predictions[predictions < 1e-10] = 1e-10
return np.sum(np.multiply(labels, -np.log(predictions))) / labels.shape[0]
Run Code Online (Sandbox Code Playgroud)
正如@MosesKoledoye和其他各方所指出的那样,它实际上是一个Numpy阵列.(Numpy是一个Python库)
这条线做什么?