我正在使用Tensorflow r0.12.
我在本地使用google-cloud-ml来运行2个不同的培训工作.在第一份工作中,我找到了我的变量的良好初始值.我将它们存储在V2检查点中.
当我尝试恢复我的变量以便在第二个作业中使用它们时:
import tensorflow as tf
sess = tf.Session()
new_saver = tf.train.import_meta_graph('../variables_pred/model.ckpt-10151.meta', clear_devices=True)
new_saver.restore(sess, tf.train.latest_checkpoint('../variables_pred/'))
all_vars = tf.trainable_variables()
for v in all_vars:
print(v.name)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
tensorflow.python.framework.errors_impl.InternalError: Unable to get element from the feed as bytes.
Run Code Online (Sandbox Code Playgroud)
在第一个作业中使用这些行创建检查点:
saver = tf.train.Saver()
saver.export_meta_graph(filename=os.path.join(output_dir, 'export.meta'))
saver.save(sess, os.path.join(output_dir, 'export'), write_meta_graph=False)
Run Code Online (Sandbox Code Playgroud)
根据这个答案,它可能来自缺少元数据文件,但我正在加载元数据文件.
PS:我使用这个论点clear_devices=True是因为在google-cloud-ml上发布产生的设备规格非常错综复杂,我不需要一定得到同样的调度.
我正在构建一个 Word2Vec 模型,用于在包含 ~35.000 个句子的数据集上进行类别推荐,总共 ~500.000 个单词,但只有 ~3.000 个不同的单词。我基本上是这样构建模型的:
def train_w2v_model(df, epochs):
w2v_model = Word2Vec(min_count=5,
window=100,
size=230,
sample=0,
workers=cores-1,
batch_words=100)
vocab = df['sentences'].apply(list)
w2v_model.build_vocab(vocab)
w2v_model.train(vocab, total_examples=w2v_model.corpus_count, total_words=w2v_model.corpus_total_words, epochs=epochs, compute_loss=True)
return w2v_model.get_latest_training_loss()
Run Code Online (Sandbox Code Playgroud)
我试图为这样的模型找到合适的时代数:
print(train_w2v_model(1))
=>> 86898.2109375
print(train_w2v_model(100))
=>> 5025273.0
Run Code Online (Sandbox Code Playgroud)
我发现结果非常违反直觉。我不明白增加 epoch 的数量会导致性能下降。这似乎不是函数的误解,get_latest_training_loss因为我观察到函数的结果most_similar更好,只有 1 个 epoch :
100 个时代:
w2v_model.wv.most_similar(['machine_learning'])
=>> [('salesforce', 0.3464601933956146),
('marketing_relationnel', 0.3125850558280945),
('batiment', 0.30903393030166626),
('go', 0.29414454102516174),
('simulation', 0.2930642068386078),
('data_management', 0.28968319296836853),
('scraping', 0.28260597586631775),
('virtualisation', 0.27560457587242126),
('dataviz', 0.26913416385650635),
('pandas', 0.2685554623603821)]
Run Code Online (Sandbox Code Playgroud)
1个时代:
w2v_model.wv.most_similar(['machine_learning'])
=>> [('data_science', 0.9953729510307312),
('data_mining', 0.9930223822593689), …Run Code Online (Sandbox Code Playgroud) 在我想要启动的模型中,我有一些必须用特定值初始化的变量.
我目前将这些变量存储到numpy数组中,但我不知道如何调整我的代码以使其适用于google-cloud-ml作业.
目前我初始化我的变量如下:
my_variable = variables.model_variable('my_variable', shape=None, dtype=tf.float32, initializer=np.load('datasets/real/my_variable.npy'))
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗 ?
我有一个像这样的pandas Dataframe:
year week city avg_rank
0 2016 52 Paris 1
1 2016 52 Gif-sur-Yvette 2
2 2016 52 Paris 1
3 2017 1 Paris 4
4 2016 52 Paris 3
5 2016 52 Paris 5
6 2016 52 Paris 2
Run Code Online (Sandbox Code Playgroud)
但是这个代码行:
df['real_index']=df.groupby(by=['year', 'week', 'city']).avg_rank.rank(method='first')
Run Code Online (Sandbox Code Playgroud)
生成堆栈跟踪:
/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in rank(self, axis, method, numeric_only, na_option, ascending, pct)
/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in wrapper(*args, **kwargs)
590 *args, **kwargs)
591 except(AttributeError):
592 raise ValueError
593
594 return wrapper
ValueError:
Run Code Online (Sandbox Code Playgroud)
我NaN在DataFrame的那些列中没有任何价值.
我使用的python2.7一起pandas 0.18.1 …