我想使用catboost最近由Yandex发布给开源社区的项目.但是,我在我的项目中使用Python 3.我知道Python 3是由Yandex皇帝禁止的.是否catboost支持Python 3里?
我成功安装了CatBoost
pip install catboost
Run Code Online (Sandbox Code Playgroud)
但是当我在Jupiter Notebook中尝试使用示例python脚本时,我遇到了错误
import numpy as np
from catboost import CatBoostClassifier
ImportError: No module named '_catboost'
ImportError: DLL load failed: ?? ?????? ????????? ??????.
Run Code Online (Sandbox Code Playgroud)
链接到CatBoost网站:https://catboost.yandex/
我尝试恢复会话并调用get_variable()以获取类型为tf.Variable的对象(根据此答案).它无法找到变量.重现案例的最小例子如下.
首先,创建一个变量并保存会话.
import tensorflow as tf
var = tf.Variable(101)
with tf.Session() as sess:
with tf.variable_scope(''):
scoped_var = tf.get_variable('scoped_var', [])
with tf.variable_scope('', reuse=True):
new_scoped_var = tf.get_variable('scoped_var', [])
assert scoped_var is new_scoped_var
sess.run(tf.global_variables_initializer())
saver = tf.train.Saver()
print(sess.run(scoped_var))
saver.save(sess, 'data/sess')
Run Code Online (Sandbox Code Playgroud)
这里get_variables有一个reuse=True工作正常的范围.然后,从文件中恢复会话并尝试获取变量.
import tensorflow as tf
with tf.Session() as sess:
saver = tf.train.import_meta_graph('data/sess.meta')
saver.restore(sess, 'data/sess')
for v in tf.get_collection('variables'):
print(v.name)
print(tf.get_collection(("__variable_store",)))
# Oops, it's empty!
with tf.variable_scope('', reuse=True):
# the next line fails
new_scoped_var = tf.get_variable('scoped_var', …Run Code Online (Sandbox Code Playgroud) 我将探讨如何在图中表示变量.我创建一个变量,初始化它并在每个动作后创建图形快照:
import tensorflow as tf
def dump_graph(g, filename):
with open(filename, 'w') as f:
print(g.as_graph_def(), file=f)
g = tf.get_default_graph()
var = tf.Variable(2)
dump_graph(g, 'data/after_var_creation.graph')
init = tf.global_variables_initializer()
dump_graph(g, 'data/after_initializer_creation.graph')
with tf.Session() as sess:
sess.run(init)
dump_graph(g, 'data/after_initializer_run.graph')
Run Code Online (Sandbox Code Playgroud)
变量创建后的图形看起来像
node {
name: "Variable/initial_value"
op: "Const"
attr {
key: "dtype"
value {
type: DT_INT32
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
}
int_val: 2
}
}
}
}
node {
name: "Variable"
op: "VariableV2"
attr {
key: …Run Code Online (Sandbox Code Playgroud)