You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/08/03 20:36:44 UTC

[incubator-mxnet] branch dev updated: Fixed Python 3 compatibility with sys.version_info (#6477)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6dadbf2  Fixed Python 3 compatibility with sys.version_info (#6477)
6dadbf2 is described below

commit 6dadbf24aefe0940917d4800c8b5e49800ce867f
Author: KW Lam <kl...@yahoo.co.uk>
AuthorDate: Fri Aug 4 04:36:40 2017 +0800

    Fixed Python 3 compatibility with sys.version_info (#6477)
    
    Updated as suggested by mxnet earlier.
---
 example/reinforcement-learning/dqn/atari_game.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/example/reinforcement-learning/dqn/atari_game.py b/example/reinforcement-learning/dqn/atari_game.py
index 369016f..3a2a0e7 100644
--- a/example/reinforcement-learning/dqn/atari_game.py
+++ b/example/reinforcement-learning/dqn/atari_game.py
@@ -27,18 +27,29 @@ def ale_load_from_rom(rom_path, display_screen):
                            'installation guidance')
 
     ale = ALEInterface()
+    import sys
+    if sys.version_info.major == 3:
+        seed_type_string_text = 'random_seed'.encode('utf-8')
+        display_screen_string_text = 'display_screen'.encode('utf-8')
+        rom_path_string_text = rom_path.encode('utf-8')
+        repeat_action_probability_string_text = 'repeat_action_probability'.encode('utf-8')
+    else:
+        seed_type_string_text = 'random_seed'
+        display_screen_string_text = 'display_screen'
+        rom_path_string_text = rom_path
+        repeat_action_probability_string_text = 'repeat_action_probability'
     ale.setInt('random_seed', rng.randint(1000))
+    ale.setInt(seed_type_string_text, rng.randint(1000))
     if display_screen:
-        import sys
         if sys.platform == 'darwin':
             import pygame
             pygame.init()
             ale.setBool('sound', False) # Sound doesn't work on OSX
-        ale.setBool('display_screen', True)
+        ale.setBool(display_screen_string_text, True)
     else:
-        ale.setBool('display_screen', False)
-    ale.setFloat('repeat_action_probability', 0)
-    ale.loadROM(rom_path)
+        ale.setBool(display_screen_string_text, False)
+    ale.setFloat(repeat_action_probability_string_text, 0)
+    ale.loadROM(rom_path_string_text)
     return ale
 
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].