0
나는 Tencentflow를 사용하여 Game of Life를 구현하고 matplotlib.animation을 사용하여 애니메이션을 묘사하려고합니다. 이미지가 표시되지만 어떤 이유로 든 움직이지는 않지만.Tensorflow + Matplotlib animation
참조 : http://learningtensorflow.com/lesson8/
IDE : Pycharm 커뮤니티 에디션 FuncAnimation에서 거짓 내가 블릿을 전달하고
=이 블릿와 Mac에서 작동하지 않습니다으로 = 진정한
다음은 내가 사용하고있는 코드는shape = (50, 50)
initial_board = tf.random_uniform(shape, minval=0, maxval=2, dtype=tf.int32)
board = tf.placeholder(tf.int32, shape=shape, name='board')
def update_board(X):
# Check out the details at: https://jakevdp.github.io/blog/2013/08/07/conways-game-of-life/
# Compute number of neighbours,
N = convolve2d(X, np.ones((3, 3)), mode='same', boundary='wrap') - X
# Apply rules of the game
X = (N == 3) | (X & (N == 2))
return X
board_update = tf.py_func(update_board, [board], [tf.int32])
fig = plt.figure()
if __name__ == '__main__':
with tf.Session() as sess:
initial_board_values = sess.run(initial_board)
X = sess.run(board_update, feed_dict={board: initial_board_values})[0]
def game_of_life(*args):
A = sess.run(board_update, feed_dict={board: X})[0]
plot.set_array(A)
return plot,
ani = animation.FuncAnimation(fig, game_of_life, interval=100, blit=False)
plot = plt.imshow(X, cmap='Greys', interpolation='nearest')
plt.show()