我正在尝试重新训练最后一层inception-resnet-v2.这是我想出的:
train_op
以尽量减少这些变量损失我实现如下:
with slim.arg_scope(arg_scope):
logits = model(images_ph, is_training=True, reuse=None)
loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits, labels_ph))
accuracy = tf.contrib.metrics.accuracy(tf.argmax(logits, 1), labels_ph)
train_list = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, 'InceptionResnetV2/Logits')
optimizer = tf.train.AdamOptimizer(learning_rate=FLAGS.learning_rate)
train_op = optimizer.minimize(loss, var_list=train_list)
# restore all variables whose names doesn't contain 'logits'
restore_list = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope='^((?!Logits).)*$')
saver = tf.train.Saver(restore_list, write_version=tf.train.SaverDef.V2)
with tf.Session() as session:
init_op = tf.group(tf.local_variables_initializer(), tf.global_variables_initializer())
session.run(init_op)
saver.restore(session, '../models/inception_resnet_v2_2016_08_30.ckpt')
# followed by code for running train_op
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用(训练损失,错误从初始值不会有太大改善).有没有更好/更优雅的方式来做到这一点?如果你能告诉我这里出了什么问题,那对我来说也不错.
PyCharm检查每个导入的模块(不在标准库中),requirements.txt
但对于某些模块(例如:grpcio
vs grpc
),包名称与模块名称不同.在这种情况下,有没有办法让警告静音?
我有一个GraphDef
我正在导入的原型文件tf.import_graph_def
.可以在图的末尾添加Ops,如下所示:
final_tensor = tf.import_graph_def(graph_def, name='', return_elements=['final_tensor'])
new_tensor = some_op(final_tensor)
Run Code Online (Sandbox Code Playgroud)
但是我想在图的开头添加Ops,所以graph_def中的第一个Op基本上需要将我的Op的输出作为输入,我该怎么做?
我正在尝试使用numpy来评估多项式(3度).我发现通过更简单的python代码来实现它会更有效率.
import numpy as np
import timeit
m = [3,7,1,2]
f = lambda m,x: m[0]*x**3 + m[1]*x**2 + m[2]*x + m[3]
np_poly = np.poly1d(m)
np_polyval = lambda m,x: np.polyval(m,x)
np_pow = lambda m,x: np.power(x,[3,2,1,0]).dot(m)
print 'result={}, timeit={}'.format(f(m,12),timeit.Timer('f(m,12)', 'from __main__ import f,m').timeit(10000))
result=6206, timeit=0.0036780834198
print 'result={}, timeit={}'.format(np_poly(12),timeit.Timer('np_poly(12)', 'from __main__ import np_poly').timeit(10000))
result=6206, timeit=0.180546045303
print 'result={}, timeit={}'.format(np_polyval(m,12),timeit.Timer('np_polyval(m,12)', 'from __main__ import np_polyval,m').timeit(10000))
result=6206, timeit=0.227771043777
print 'result={}, timeit={}'.format(np_pow(m,12),timeit.Timer('np_pow(m,12)', 'from __main__ import np_pow,m').timeit(10000))
result=6206, timeit=0.168987989426
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
numpy中还有另一种评估多项式的方法吗?
我在 div 中有一个视频和一个画布,我想将画布覆盖在视频上。我试过这个:
.container {
margin: 0 auto;
position: relative;
}
.video {
width: 100%;
height: auto;
position: absolute;
top: 0;
left: 0;
}
.canvas {
width: 100%;
height: auto;
position: absolute;
top: 0;
left: 0;
z-index: 10;
}
Run Code Online (Sandbox Code Playgroud)
JSFiddle在这里
但是由于某种原因画布没有覆盖整个视频,它更短。我该如何解决?
正如标题所示,tf.nn.space_to_depth是否有等效的 PyTorch 函数?
我有以下代码:
import numpy as np
from scipy import sparse
x = np.eye(3)
print(x.sum(axis=1).shape)
x = sparse.eye(3)
print(x.sum(axis=1).shape)
print(x.sum(axis=1).squeeze().shape)
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
(3,)
(3, 1)
(1, 3)
Run Code Online (Sandbox Code Playgroud)
看起来squeeze
没有按预期工作。我究竟做错了什么?
以下是本地(在localhost上)在谷歌应用引擎上运行的log.php文件.
<?php
if (isset($_POST['name'])) {
$name = $_POST['name'];
$filename = "log.txt";
file_put_contents($filename, $name, FILE_APPEND | LOCK_EX);
}
?>
Run Code Online (Sandbox Code Playgroud)
我使用以下jquery调用调用上面的文件:
$.ajax({
url: './php/log.php',
type: 'POST',
data: {name: name},
success: function (data) {
console.log(data);
}
});
Run Code Online (Sandbox Code Playgroud)
我相信ajax正在工作,因为我得到一个登录控制台,这只是整个PHP代码.但是php没有在log.txt文件中写入任何内容.有人可以帮忙吗?
python ×4
tensorflow ×3
numpy ×2
canvas ×1
css ×1
html ×1
javascript ×1
jquery ×1
performance ×1
php ×1
pip ×1
polynomials ×1
pycharm ×1
pytorch ×1
scipy ×1