我想在张量流或keras中重复数据,您可以使用void print_player_info(Player * const p) {
// only prints the player info so no ownership is taken
// p is only use within print_player_info
cout << "Name is:" << p->getName() << "\n";
}
int main()
{
Game Game1;
Game1.addPlayer(std::move(std::make_unique<Player>(0, "Player1"));
Game1.addPlayer(std::move(std::make_unique<Player>(0, "Player2"));
print_player_info(Game1.playerList[1]->get());
return 0;
}
将tf.tile
重复到[a, b, c]
。但是,是否有任何简单的方法来获取[a, b, c, a, b, c]
?
答案 0 :(得分:1)
尝试:
import tensorflow as tf
a = tf.constant(['a','b','c'], dtype=tf.string)
result = tf.reshape(tf.stack([a,a],axis=1), shape=(-1,))
with tf.Session() as sess:
print(sess.run(result))
# print
[b'a' b'a' b'b' b'b' b'c' b'c']
答案 1 :(得分:0)
不幸的是,要实现您想要的功能有点麻烦。在这里,您去了:
X = tf.constant([1, 2, 3])
expanded = tf.expand_dims(X, axis=-1)
#[[1]
# [2]
# [3]]
tiled = tf.tile(expanded,[1,2])
# [[1 1]
# [2 2]
# [3 3]]
reshaped = tf.reshape(tiled,[-1])
# [1 1 2 2 3 3]