contact_angle_and_wetting_properties.pdf |
cavitation_and_bubble_dynamics.pdf |
|
Comments
Imagine that we have
y_d = tf.matmul(activation_d, W_out_d) + b_out_d Now if we want to apply sigmoid function to the first three columns of y_d while taking absolute value of the fourth column, what should we do? Since 'Tensor' object does not support item assignment, we need to use tf.slice to slice the tensor first so that we can manipulate each slice separately and use tf.concat to join them back together. The code for the above purpose is as follows: y_d1=tf.slice(y_d, [0,0],[-1,3]) #-1 tells TensorFlow all the rows are needed; 3 is the column number (size). y_d1=tf.nn.sigmoid(y_d1) y_d2=tf.slice(y_d, [0,3],[-1,1]) y_d2=tf.abs(y_d2) y_d=tf.concat([y_d1, y_d2], 1) tf.slice: https://www.tensorflow.org/api_docs/python/tf/slice tf.concat: https://www.tensorflow.org/api_docs/python/tf/concat CSV file introduction:
https://tools.ietf.org/html/rfc4180 #Relevant import import numpy as np import tensorflow as tf To read text files in comma-separated value (CSV) format, use a tf.TextLineReader with the tf.decode_csv operation. TensorFlow data reading: https://www.tensorflow.org/programmers_guide/reading_data Sample code: # Initialize init = tf.global_variables_initializer() sess = tf.Session() sess.run(init) filename_queue = tf.train.string_input_producer(["X_IN_Y_TARGET.txt"]) reader=tf.TextLineReader() key,value=reader.read(filename_queue) record_defaults=[[1.000000],[1.000000],[1.000000]] # Default values, in case of empty columns. Also specifies the type of the decoded result. col1,col2, col3=tf.decode_csv(value, record_defaults=record_defaults) # Read each column. In this example, col 1 and 2 are inputs and col 3 is the actual output. xin=tf.stack([col1,col2]) # Stack two columns into one tensor as the input. coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord,sess=sess) example= sess.run([xin,col3]) #Read one instance (one line of data only). "example" is an array. batch_x=np.array([example[0]], np.float32) #Convert the first element of the array (xin) into nparray. batch_y=np.array([example[1]], np.float32) # Load 3995 more lines of data into batch_x and y. for i in range(3995): # Retrieve a single instance: example= sess.run([xin,col3]) batch_x = np.vstack((batch_x, [example[0]])) # Add row to the input array. batch_y = np.vstack((batch_y, [example[1]])) #Now batch_x and y are nparray and can be used for TensorFlow neural network training. 1. Download Python 3.5.x
https://www.python.org/downloads/release/python-352/ May need to remove previous Python version Add Python 3.5.x to the PATH 2. Follow the instructions https://www.tensorflow.org/install/install_windows You may need the following link when pip is not recognized: http://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command Target:
1. Go to the Jobs page; search with user specified keyword and location. 2. Crawl through all the job openings and save them in local file. Target: 1. Achieve web browser automation with Selenium. 2. Log into LinkedIn.com with email and password and start crawling connection information. -------------------------------------------------------------------------------------------------------------------------------------------------- Special libraries required: Selenium BeautifulSoup To use selenium.webdriver.Chrome() , Chrome driver needs to be put in the directory. Download link: http://chromedriver.storage.googleapis.com/index.html Other popular browsers are also available. -------------------------------------------------------------------------------------------------------------------------------------------------- Code samples: Set up automated Chrome browser: browser = webdriver.Chrome() Open LinkedIn login page: browser.get("https://linkedin.com/uas/login") (Sometimes sleep time might be required before using browser.get(). time.sleep(random.uniform(3.5, 6.9)) Randomness is recommended.) Get the id of password box and fill in the password. Submit at the end. passElement = browser.find_element_by_id("session_password-login") passElement.send_keys(password) passElement.submit() It is recommended to clear the element input first before send the keys using: element.clear() Close the browser at the end of use: browser.close() -------------------------------------------------------------------------------------------------------------------------------------------------- Result: All targets are reached.
|
Jingwei ZhuPh.D. candidate in the Department of Mechanical Science and Engineering at the University of Illinois at Urbana-Champaign. Categories
All
Archives
October 2018
|