我试图在Tensorflow中做回归.我不是肯定的我正在正确计算R ^ 2,因为Tensorflow给了我一个不同的答案,sklearn.metrics.r2_score有人可以看看我的下面的代码,让我知道我是否正确实现了图像方程.谢谢
total_error = tf.square(tf.sub(y, tf.reduce_mean(y)))
unexplained_error = tf.square(tf.sub(y, prediction))
R_squared = tf.reduce_mean(tf.sub(tf.div(unexplained_error, total_error), 1.0))
R = tf.mul(tf.sign(R_squared),tf.sqrt(tf.abs(R_squared)))
Run Code Online (Sandbox Code Playgroud) 一直在寻找,但似乎无法找到任何关于如何从TensorFlow中的单热值解码或转换回单个整数的示例.
我用过tf.one_hot并且能够训练我的模型,但是在分类之后我对如何理解标签感到有点困惑.我的数据是通过TFRecords我创建的文件输入的.我想过在文件中存储文本标签但是无法让它工作.看起来似乎TFRecords无法存储文本字符串或者我错了.
我正在尝试使用 Gunicorn/WSGI/Nginx 部署 FlaskApp。我一直试图让它工作一段时间,除了我遵循的数字海洋指南之外找不到任何其他东西。下面是我在当前状态下的文件。我尝试了几种不同的调整mywebapp.service文件,因为我很确定这就是我的问题所在。我可以跑步/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 -u nginx -g nginx wsgi,gunicorn 会起作用。我很确定这是我遗漏的一些可能是基本的小东西,但我丢失了。我的nginx用户拥有应用程序目录。
? mywebapp.service - Gunicorn instance to serve mywebapp
Loaded: loaded (/etc/systemd/system/mywebapp.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2018-06-30 13:00:35 EDT; 25min ago
Main PID: 29706 (code=exited, status=203/EXEC)
Jun 30 13:00:35 localhost.localdomain systemd[1]: Started Gunicorn instance to serve mywebapp.
Jun 30 13:00:35 localhost.localdomain systemd[1]: Starting Gunicorn instance to serve mywebapp...
Jun 30 …Run Code Online (Sandbox Code Playgroud) 我尝试构建一些函数来填充我的新 Neo4j 图表,但我很难使用 Py2Neo v4 和 Neo4j 3.4.7 将日期填充为 Neo4j 中的正确数据类型。根据 Neo4j文档,有日期时间数据类型...以及我也想获得的空间点
我一生都无法在 Py2Neo 中找到任何使用空间点或时间点的文档。我发现 Py2Neo v2 中有一个针对这些数据类型的插件,但还没有找到其他任何东西。
我可以将 Pythondatetime.datetime对象作为节点属性发送到 Neo4j,但是当我尝试使用 Cypher 查询时,它不承认它的格式正确。
# python/py2neo code being used to make the node
example_node = Node("Example", date=datetime.datetime.now())
tx.create(example_node)
Run Code Online (Sandbox Code Playgroud)
# cypher query
MATCH (e:Example)
WHERE e.date > datetime("2018-12-31")
RETURN e
Run Code Online (Sandbox Code Playgroud)
注意:如果我像这样进行e.date转换,则会出现语法错误:datetimedatetime(e.date)
Neo.ClientError.Statement.SyntaxError: Text cannot be parsed to a DateTime
"2019-01-14 13:00:52"
Run Code Online (Sandbox Code Playgroud)
任何在 Py2neo 中找到适当文档的帮助,或者甚至是更好的驱动程序,都将不胜感激。
谢谢
我试图通过在字符串中插入变量的值来在Julia中创建动态字符串。直到今天,当值返回时,一切仍然正常,这nothing给我带来了错误。
如何nothing在字符串中包含a ?至少不必if n == nothing; n = "None"为要插入字符串中的每个变量都麻烦。
function charge_summary(charges_df)
if size(charges_df)[1] > 0
n_charges = size(charges_df)[1]
total_charges = round(abs(sum(charges_df[:amount])), digits=2)
avg_charges = round(abs(mean(charges_df[:amount])), digits=2)
most_frequent_vender = first(sort(by(charges_df, :transaction_description, nrow), :x1, rev=true))[:transaction_description]
sms_text = """You have $n_charges new transactions, totaling \$$total_charges.
Your average expenditure is \$$avg_charges.
Your most frequented vender is $most_frequent_vender.
"""
return sms_text
else
return nothing
end
end
sms_msg = charge_summary(charges_df)
Run Code Online (Sandbox Code Playgroud)
返回值:
ArgumentError: `nothing` should not be printed; use `show`, `repr`, …Run Code Online (Sandbox Code Playgroud) 我整天都花在这上面,并且不知道我做错了什么.请帮忙.我使用以下代码创建了包含一些图像的TFRecords文件:
def convert_to_TF(images, labels, name):
label_count = labels.shape[0]
print('There are %d images in this dataset.' % (label_count))
if images.shape[0] != label_count:
raise ValueError('WTF! Devil! There are %d images and %d labels. Go fix yourself!' %
(images.shape[0], label_count))
rows = images.shape[1]
cols = images.shape[2]
depth = images.shape[3]
filename = os.path.join(name + '.tfrecords')
print('Writing', filename)
writer = tf.python_io.TFRecordWriter(filename)
for index in range(label_count):
image_raw = images[index].tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(int(labels[index])),
'image_raw': _bytes_feature(image_raw)}))
writer.write(example.SerializeToString())
Run Code Online (Sandbox Code Playgroud)
然后我尝试用以下内容读取保存的TFRecords文件:
def read_and_decode(filename_queue): …Run Code Online (Sandbox Code Playgroud) python ×3
tensorflow ×3
datetime ×1
flask ×1
gunicorn ×1
julia ×1
neo4j ×1
nginx ×1
python-3.x ×1
regression ×1
wsgi ×1