├── .DS_Store ├── .gitignore ├── .idea ├── Auto-GUI-Code-Generation.iml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── LICENSE ├── README.md ├── compiler ├── android-compiler.py ├── assets │ ├── android-dsl-mapping.json │ ├── ios-dsl-mapping.json │ └── web-dsl-mapping.json ├── classes │ ├── Compiler.py │ ├── Node.py │ ├── Utils.py │ └── __init__.py ├── ios-compiler.py └── web-compiler.py ├── model ├── .DS_Store ├── Extract_features.py ├── __init__.py ├── __pycache__ │ └── __init__.cpython-36.pyc ├── classes │ ├── .DS_Store │ ├── Utils.py │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-36.pyc │ ├── dataset │ │ ├── .DS_Store │ │ └── __init__.py │ └── model │ │ ├── .DS_Store │ │ ├── Config.py │ │ ├── __init__.py │ │ └── __pycache__ │ │ ├── Config.cpython-36.pyc │ │ └── __init__.cpython-36.pyc └── data_process.py ├── requirements.txt ├── test.py └── tmp └── events.out.tfevents.1557014393.zhuzhihaodeMBP.wv.cc.cmu.edu /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /datasets 2 | -------------------------------------------------------------------------------- /.idea/Auto-GUI-Code-Generation.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | ke 49 | keras 50 | config 51 | image_size 52 | 53 | 54 | 55 | 57 | 58 | 70 | 71 | 72 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | ") 19 | exit(0) 20 | 21 | TEXT_PLACE_HOLDER = "[TEXT]" 22 | ID_PLACE_HOLDER = "[ID]" 23 | 24 | dsl_path = "assets/android-dsl-mapping.json" 25 | compiler = Compiler(dsl_path) 26 | 27 | 28 | def render_content_with_text(key, value): 29 | value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text(length_text=5, space_number=0)) 30 | while value.find(ID_PLACE_HOLDER) != -1: 31 | value = value.replace(ID_PLACE_HOLDER, Utils.get_android_id(), 1) 32 | return value 33 | 34 | file_uid = basename(input_file)[:basename(input_file).find(".")] 35 | path = input_file[:input_file.find(file_uid)] 36 | 37 | input_file_path = "{}{}.gui".format(path, file_uid) 38 | output_file_path = "{}{}.xml".format(path, file_uid) 39 | 40 | compiler.compile(input_file_path, output_file_path, rendering_function=render_content_with_text) 41 | -------------------------------------------------------------------------------- /compiler/assets/android-dsl-mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "opening-tag": "{", 3 | "closing-tag": "}", 4 | "body": "\n\n {}\n\n", 5 | "stack": "\n \n {}\n \n", 6 | "row": "\n{}\n", 7 | "label": "\n", 8 | "btn": "", 12 | "footer": "\n \n \n \n \n {}\n \n", 13 | "btn-search": "", 14 | "btn-contact": "", 15 | "btn-download": "", 16 | "btn-more": "" 17 | } 18 | -------------------------------------------------------------------------------- /compiler/assets/web-dsl-mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "opening-tag": "{", 3 | "closing-tag": "}", 4 | "body": "\n
\n \n \n \n\n\n Scaffold\n
\n \n
\n {}\n
\n

© Tony Beltramelli 2017

\n
\n
\n \n \n \n\n", 5 | "header": "
\n \n
\n", 6 | "btn-active": "
  • []
  • \n", 7 | "btn-inactive": "
  • []
  • \n", 8 | "row": "
    {}
    \n", 9 | "single": "
    \n{}\n
    \n", 10 | "double": "
    \n{}\n
    \n", 11 | "quadruple": "
    \n{}\n
    \n", 12 | "btn-green": "[]\n", 13 | "btn-orange": "[]\n", 14 | "btn-red": "[]", 15 | "big-title": "

    []

    ", 16 | "small-title": "

    []

    ", 17 | "text": "

    []

    \n" 18 | } 19 | -------------------------------------------------------------------------------- /compiler/classes/Compiler.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = 'Tony Beltramelli - www.tonybeltramelli.com' 3 | 4 | import json 5 | from classes.Node import * 6 | 7 | 8 | class Compiler: 9 | def __init__(self, dsl_mapping_file_path): 10 | with open(dsl_mapping_file_path) as data_file: 11 | self.dsl_mapping = json.load(data_file) 12 | 13 | self.opening_tag = self.dsl_mapping["opening-tag"] 14 | self.closing_tag = self.dsl_mapping["closing-tag"] 15 | self.content_holder = self.opening_tag + self.closing_tag 16 | 17 | self.root = Node("body", None, self.content_holder) 18 | 19 | def compile(self, input_file_path, output_file_path, rendering_function=None): 20 | dsl_file = open(input_file_path) 21 | current_parent = self.root 22 | 23 | for token in dsl_file: 24 | token = token.replace(" ", "").replace("\n", "") 25 | 26 | if token.find(self.opening_tag) != -1: 27 | token = token.replace(self.opening_tag, "") 28 | 29 | element = Node(token, current_parent, self.content_holder) 30 | current_parent.add_child(element) 31 | current_parent = element 32 | elif token.find(self.closing_tag) != -1: 33 | current_parent = current_parent.parent 34 | else: 35 | tokens = token.split(",") 36 | for t in tokens: 37 | element = Node(t, current_parent, self.content_holder) 38 | current_parent.add_child(element) 39 | 40 | output_html = self.root.render(self.dsl_mapping, rendering_function=rendering_function) 41 | with open(output_file_path, 'w') as output_file: 42 | output_file.write(output_html) 43 | -------------------------------------------------------------------------------- /compiler/classes/Node.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | __author__ = 'Tony Beltramelli - www.tonybeltramelli.com' 4 | 5 | 6 | class Node: 7 | def __init__(self, key, parent_node, content_holder): 8 | self.key = key 9 | self.parent = parent_node 10 | self.children = [] 11 | self.content_holder = content_holder 12 | 13 | def add_child(self, child): 14 | self.children.append(child) 15 | 16 | def show(self): 17 | print(self.key) 18 | for child in self.children: 19 | child.show() 20 | 21 | def render(self, mapping, rendering_function=None): 22 | content = "" 23 | for child in self.children: 24 | content += child.render(mapping, rendering_function) 25 | 26 | value = mapping[self.key] 27 | if rendering_function is not None: 28 | value = rendering_function(self.key, value) 29 | 30 | if len(self.children) != 0: 31 | value = value.replace(self.content_holder, content) 32 | 33 | return value 34 | -------------------------------------------------------------------------------- /compiler/classes/Utils.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tony Beltramelli - www.tonybeltramelli.com' 2 | 3 | import string 4 | import random 5 | 6 | 7 | class Utils: 8 | @staticmethod 9 | def get_random_text(length_text=10, space_number=1, with_upper_case=True): 10 | results = [] 11 | while len(results) < length_text: 12 | char = random.choice(string.ascii_letters[:26]) 13 | results.append(char) 14 | if with_upper_case: 15 | results[0] = results[0].upper() 16 | 17 | current_spaces = [] 18 | while len(current_spaces) < space_number: 19 | space_pos = random.randint(2, length_text - 3) 20 | if space_pos in current_spaces: 21 | break 22 | results[space_pos] = " " 23 | if with_upper_case: 24 | results[space_pos + 1] = results[space_pos - 1].upper() 25 | 26 | current_spaces.append(space_pos) 27 | 28 | return ''.join(results) 29 | 30 | @staticmethod 31 | def get_ios_id(length=10): 32 | results = [] 33 | 34 | while len(results) < length: 35 | char = random.choice(string.digits + string.ascii_letters) 36 | results.append(char) 37 | 38 | results[3] = "-" 39 | results[6] = "-" 40 | 41 | return ''.join(results) 42 | 43 | @staticmethod 44 | def get_android_id(length=10): 45 | results = [] 46 | 47 | while len(results) < length: 48 | char = random.choice(string.ascii_letters) 49 | results.append(char) 50 | 51 | return ''.join(results) 52 | -------------------------------------------------------------------------------- /compiler/classes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/compiler/classes/__init__.py -------------------------------------------------------------------------------- /compiler/ios-compiler.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | __author__ = 'Tony Beltramelli - www.tonybeltramelli.com' 4 | 5 | import sys 6 | 7 | from os.path import basename 8 | from classes.Utils import * 9 | from classes.Compiler import * 10 | 11 | if __name__ == "__main__": 12 | argv = sys.argv[1:] 13 | length = len(argv) 14 | if length != 0: 15 | input_file = argv[0] 16 | else: 17 | print("Error: not enough argument supplied:") 18 | print("ios-compiler.py ") 19 | exit(0) 20 | 21 | TEXT_PLACE_HOLDER = "[TEXT]" 22 | ID_PLACE_HOLDER = "[ID]" 23 | 24 | dsl_path = "assets/ios-dsl-mapping.json" 25 | compiler = Compiler(dsl_path) 26 | 27 | 28 | def render_content_with_text(key, value): 29 | value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text(length_text=6, space_number=0)) 30 | while value.find(ID_PLACE_HOLDER) != -1: 31 | value = value.replace(ID_PLACE_HOLDER, Utils.get_ios_id(), 1) 32 | return value 33 | 34 | file_uid = basename(input_file)[:basename(input_file).find(".")] 35 | path = input_file[:input_file.find(file_uid)] 36 | 37 | input_file_path = "{}{}.gui".format(path, file_uid) 38 | output_file_path = "{}{}.storyboard".format(path, file_uid) 39 | 40 | compiler.compile(input_file_path, output_file_path, rendering_function=render_content_with_text) 41 | -------------------------------------------------------------------------------- /compiler/web-compiler.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | 4 | import sys 5 | 6 | from os.path import basename 7 | from classes.Utils import * 8 | from classes.Compiler import * 9 | 10 | if __name__ == "__main__": 11 | argv = sys.argv[1:] 12 | length = len(argv) 13 | if length != 0: 14 | input_file = argv[0] 15 | else: 16 | print("Error: not enough argument supplied:") 17 | print("web-compiler.py ") 18 | exit(0) 19 | 20 | FILL_WITH_RANDOM_TEXT = True 21 | TEXT_PLACE_HOLDER = "[]" 22 | 23 | dsl_path = "assets/web-dsl-mapping.json" 24 | compiler = Compiler(dsl_path) 25 | 26 | 27 | def render_content_with_text(key, value): 28 | if FILL_WITH_RANDOM_TEXT: 29 | if key.find("btn") != -1: 30 | value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text()) 31 | elif key.find("title") != -1: 32 | value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text(length_text=5, space_number=0)) 33 | elif key.find("text") != -1: 34 | value = value.replace(TEXT_PLACE_HOLDER, 35 | Utils.get_random_text(length_text=56, space_number=7, with_upper_case=False)) 36 | return value 37 | 38 | file_uid = basename(input_file)[:basename(input_file).find(".")] 39 | path = input_file[:input_file.find(file_uid)] 40 | 41 | input_file_path = "{}{}.gui".format(path, file_uid) 42 | output_file_path = "{}{}.html".format(path, file_uid) 43 | 44 | compiler.compile(input_file_path, output_file_path, rendering_function=render_content_with_text) 45 | -------------------------------------------------------------------------------- /model/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/.DS_Store -------------------------------------------------------------------------------- /model/Extract_features.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | import os 3 | import tensorflow as tf 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | import matplotlib.image as mpimg 7 | 8 | from model.classes.model.Config import * 9 | tf.enable_eager_execution() 10 | platform = "web" 11 | 12 | IMG_SHAPE = (IMAGE_SIZE, IMAGE_SIZE, 3) 13 | 14 | # Create the base model from the pre-trained model VGGNET 15 | base_model = tf.keras.applications.ResNet50(input_shape=IMG_SHAPE, 16 | include_top=False, 17 | weights='imagenet') 18 | base_model.trainable = False 19 | 20 | for dataset in ("train_data","val_data","test_data"): 21 | for f in os.listdir("../datasets/{}/{}".format(platform,dataset)): 22 | sample = np.load("../datasets/{}/{}/{}".format(platform,dataset,f)) 23 | input = sample["img"][np.newaxis,...] 24 | output = base_model.apply(input) 25 | print(output) 26 | break 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/__init__.py -------------------------------------------------------------------------------- /model/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /model/classes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/.DS_Store -------------------------------------------------------------------------------- /model/classes/Utils.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | 4 | 5 | class Utils: 6 | @staticmethod 7 | def sparsify(label_vector, output_size): 8 | sparse_vector = [] 9 | 10 | for label in label_vector: 11 | sparse_label = np.zeros(output_size) 12 | sparse_label[label] = 1 13 | 14 | sparse_vector.append(sparse_label) 15 | 16 | return np.array(sparse_vector) 17 | 18 | @staticmethod 19 | def get_preprocessed_img(img_path, image_size): 20 | import cv2 21 | img = cv2.imread(img_path) 22 | img = cv2.resize(img, (image_size, image_size)) 23 | img = img.astype('float32') 24 | img /= 255 25 | return img 26 | 27 | @staticmethod 28 | def show(image): 29 | import cv2 30 | cv2.namedWindow("view", cv2.WINDOW_AUTOSIZE) 31 | cv2.imshow("view", image) 32 | cv2.waitKey(0) 33 | cv2.destroyWindow("view") 34 | -------------------------------------------------------------------------------- /model/classes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/__init__.py -------------------------------------------------------------------------------- /model/classes/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /model/classes/dataset/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/dataset/.DS_Store -------------------------------------------------------------------------------- /model/classes/dataset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/dataset/__init__.py -------------------------------------------------------------------------------- /model/classes/model/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/model/.DS_Store -------------------------------------------------------------------------------- /model/classes/model/Config.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tony Beltramelli - www.tonybeltramelli.com' 2 | 3 | CONTEXT_LENGTH = 48 4 | IMAGE_SIZE = 256 5 | BATCH_SIZE = 64 6 | EPOCHS = 10 7 | STEPS_PER_EPOCH = 72000 8 | -------------------------------------------------------------------------------- /model/classes/model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/model/__init__.py -------------------------------------------------------------------------------- /model/classes/model/__pycache__/Config.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/model/__pycache__/Config.cpython-36.pyc -------------------------------------------------------------------------------- /model/classes/model/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/model/classes/model/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /model/data_process.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import numpy as np 6 | import cv2 7 | import shutil 8 | 9 | from model.classes.model.Config import * 10 | 11 | 12 | ## Defined Functions 13 | def content_transform(string): 14 | bl_token = [] 15 | tl_token = [] 16 | stack = 0 17 | tokens = string.split(" ") 18 | bl_token.append(tokens[0]) 19 | for i in range(1,len(tokens)-1): 20 | if stack==0: 21 | if tokens[i] != "{": 22 | bl_token.append(tokens[i]) 23 | continue 24 | elif tokens[i] == "{": 25 | stack += 1 26 | else: 27 | if tokens[i] == "}": 28 | stack -= 1 29 | if stack != 0: 30 | tl_token.append(tokens[i]) 31 | elif tokens[i] == "{": 32 | stack += 1 33 | tl_token.append(tokens[i]) 34 | else: 35 | if tokens[i][-1] == ",": 36 | tl_token.append(tokens[i][:-1]) 37 | else: 38 | tl_token.append(tokens[i]) 39 | return bl_token, tl_token 40 | 41 | 42 | # arg = sys.argv[1:] 43 | # platform = arg[0] 44 | # distribution = arg[1] 45 | platform = "web" 46 | distribution = 6 47 | 48 | if not os.path.isdir("../datasets/{}/train_data".format(platform)): 49 | os.mkdir("../datasets/{}/train_data".format(platform)) 50 | 51 | if not os.path.isdir("./datasets/{}/val_data".format(platform)): 52 | os.mkdir("../datasets/{}/val_data".format(platform)) 53 | 54 | if not os.path.isdir("../datasets/{}/test_data".format(platform)): 55 | os.mkdir("../datasets/{}/test_data".format(platform)) 56 | 57 | DISTRIBUTION = 6 if not distribution else distribution 58 | 59 | path = [] 60 | for f in os.listdir("../datasets/{}/all_data".format(platform)): 61 | 62 | if f.find(".gui") != -1: 63 | file_name = f[:f.find(".gui")] 64 | path.append(file_name) 65 | 66 | ##----------Split the document and tokenize each word----------------## 67 | with open("../datasets/{}/all_data/{}".format(platform,f),'r') as file: 68 | char = "" 69 | for line in file: 70 | char += line 71 | char = char.replace("\n", " ") 72 | bl_token, tl_token = content_transform(char) 73 | 74 | image_path = "../datasets/{}/all_data/{}.png".format(platform,file_name) 75 | img = cv2.imread(image_path) 76 | img = cv2.resize(img, (256, 256)) 77 | img = img.astype('float32') 78 | img /= 255 79 | 80 | ##-----------Save the resized images and tokens into npz-----------------## 81 | np.savez_compressed("../datasets/{}/all_data/{}".format(platform, file_name), 82 | bl_token=bl_token, tl_token=tl_token, img = img) 83 | 84 | ##-----------split the data-----------------## 85 | val_size = len(path)//(DISTRIBUTION+1) 86 | np.random.shuffle(path) 87 | val_data = path[:val_size] 88 | test_data = path[val_size:val_size*2] 89 | train_data = path[2*val_size:] 90 | search_index = {0:"val_data", 1:"test_data", 2:"train_data"} 91 | 92 | ##-----------copy the data into corresponding folders-----------------## 93 | for index, set in enumerate([val_data, test_data, train_data]): 94 | for file_name in set: 95 | shutil.copyfile("../datasets/{}/all_data/{}.npz".format(platform, file_name), 96 | "../datasets/{}/{}/{}.npz".format(platform, search_index[index], file_name)) 97 | 98 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Keras==2.1.2 2 | numpy==1.13.3 3 | opencv-python==3.3.0.10 4 | h5py==2.7.1 5 | tensorflow==1.4.0 6 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | import numpy as np 3 | import os 4 | 5 | global_step = tf.Variable(0, trainable=False) 6 | increment_op = tf.assign_add(global_step, tf.constant(1)) 7 | lr = tf.train.exponential_decay(0.1, global_step, decay_steps=1, decay_rate=0.9, staircase=False) 8 | 9 | tf.summary.scalar('learning_rate', lr) 10 | 11 | sum_ops = tf.summary.merge_all() 12 | 13 | sess = tf.Session() 14 | init = tf.global_variables_initializer() 15 | sess.run(init) 16 | 17 | if not os.path.isdir("./tmp"): 18 | os.mkdir("./tmp") 19 | 20 | summary_writer = tf.summary.FileWriter('./tmp/', sess.graph) 21 | 22 | for step in range(0, 10): 23 | s_val = sess.run(sum_ops) 24 | summary_writer.add_summary(s_val, global_step=step) 25 | sess.run(increment_op) 26 | -------------------------------------------------------------------------------- /tmp/events.out.tfevents.1557014393.zhuzhihaodeMBP.wv.cc.cmu.edu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhihaoZhu/Auto-GUI-Code-Generation/484131228e59e91b2378f1c40171e65d11305ad4/tmp/events.out.tfevents.1557014393.zhuzhihaodeMBP.wv.cc.cmu.edu --------------------------------------------------------------------------------