├── AlexanderResume.pdf ├── README.md ├── Stanford_CS_PhD_2020_SOP.pdf ├── github_henrik_recommendation-1.pdf ├── github_lk_recommendation-1.pdf ├── github_ow_recommendation-1.pdf ├── old ├── rnn_decoder_example.py ├── thesis-talk.pdf └── thesis_article.pdf └── resume_latex_2021-10-10.zip /AlexanderResume.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/AlexanderResume.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Click on AlexanderResume.pdf to learn more about me or go to alrojo.github.io 2 | -------------------------------------------------------------------------------- /Stanford_CS_PhD_2020_SOP.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/Stanford_CS_PhD_2020_SOP.pdf -------------------------------------------------------------------------------- /github_henrik_recommendation-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/github_henrik_recommendation-1.pdf -------------------------------------------------------------------------------- /github_lk_recommendation-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/github_lk_recommendation-1.pdf -------------------------------------------------------------------------------- /github_ow_recommendation-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/github_ow_recommendation-1.pdf -------------------------------------------------------------------------------- /old/rnn_decoder_example.py: -------------------------------------------------------------------------------- 1 | class rnn_decoder(): 2 | def __init__(self, cell, initial_state, decoder_fn, inputs=None, 3 | sequence_length=None, output_fn=None, state_fn=None, 4 | loop_fn=None, encoder_projection=None, parallel_iterations=None, 5 | swap_memory=False, time_major=False, scope=None): 6 | self.cell = cell 7 | self.initial_state = initial_state 8 | self.decoder_fn = decoder_fn(self) 9 | self.inputs = inputs 10 | self.sequence_length = sequence_length 11 | self.encoder_projection = encoder_projection 12 | self.parallel_iterations = parallel_iterations 13 | self.swap_memory = swap_memory 14 | self.time_major = time_major 15 | self.scope = scope 16 | 17 | def run(self): 18 | if self.encoder_projection is None: 19 | # Project initial_state as described in Bahdanau et al. 2014 20 | # https://arxiv.org/abs/1409.0473 21 | self.state = layers.fully_connected(self.initial_state, self.cell.output_size, 22 | activation_fn=math_ops.tanh) 23 | else: 24 | self.state = self.initial_state 25 | # Testing input dimensions 26 | if len(self.inputs.get_shape()) is not 3: 27 | raise ValueError("Inputs must have three dimensions") 28 | if self.inputs.get_shape()[2] is None: 29 | raise ValueError("Inputs must not be `None` in the feature (3'rd) " 30 | "dimension") 31 | # Setup of RNN (dimensions, sizes, length, initial state, dtype) 32 | # Setup dtype 33 | self.dtype = self.state.dtype 34 | if not self.time_major: 35 | # [batch, seq, features] -> [seq, batch, features] 36 | self.inputs = array_ops.transpose(self.inputs, perm=[1, 0, 2]) 37 | # Get data input information 38 | self.batch_size = array_ops.shape(self.inputs)[1] 39 | self.input_depth = int(self.inputs.get_shape()[2]) 40 | # Setup decoder inputs as TensorArray 41 | self.inputs_ta = tensor_array_ops.TensorArray(self.dtype, size=0, dynamic_size=True) 42 | self.inputs_ta = self.inputs_ta.unpack(self.inputs) 43 | 44 | # Run raw_rnn function 45 | outputs_ta, _, _ = ( 46 | rnn.raw_rnn(self.cell, self.decoder_fn, 47 | parallel_iterations=self.parallel_iterations, 48 | swap_memory=self.swap_memory, scope=varscope)) 49 | outputs = outputs_ta.pack() 50 | if not self.time_major: 51 | # [seq, batch, features] -> [batch, seq, features] 52 | outputs = array_ops.transpose(outputs, perm=[1, 0, 2]) 53 | return outputs 54 | 55 | # resetting the graph 56 | reset_default_graph() 57 | 58 | # Setting up hyperparameters and general configs 59 | MAX_DIGITS = 5 60 | MIN_DIGITS = 5 61 | NUM_INPUTS = 27 62 | NUM_OUTPUTS = 11 #(0-9 + '#') 63 | 64 | BATCH_SIZE = 100 65 | # try various learning rates 1e-2 to 1e-5 66 | LEARNING_RATE = 0.005 67 | X_EMBEDDINGS = 8 68 | t_EMBEDDINGS = 8 69 | NUM_UNITS_ENC = 10 70 | NUM_UNITS_DEC = 10 71 | 72 | 73 | # Setting up placeholders, these are the tensors that we "feed" to our network 74 | Xs = tf.placeholder(tf.int32, shape=[None, None], name='X_input') 75 | ts_in = tf.placeholder(tf.int32, shape=[None, None], name='t_input_in') 76 | ts_out = tf.placeholder(tf.int32, shape=[None, None], name='t_input_out') 77 | X_len = tf.placeholder(tf.int32, shape=[None], name='X_len') 78 | t_len = tf.placeholder(tf.int32, shape=[None], name='X_len') 79 | t_mask = tf.placeholder(tf.float32, shape=[None, None], name='t_mask') 80 | 81 | # Building the model 82 | 83 | # first we build the embeddings to make our characters into dense, trainable vectors 84 | X_embeddings = tf.get_variable('X_embeddings', [NUM_INPUTS, X_EMBEDDINGS], 85 | initializer=tf.random_normal_initializer(stddev=0.1)) 86 | t_embeddings = tf.get_variable('t_embeddings', [NUM_OUTPUTS, t_EMBEDDINGS], 87 | initializer=tf.random_normal_initializer(stddev=0.1)) 88 | 89 | # setting up weights for computing the final output 90 | W_out = tf.get_variable('W_out', [NUM_UNITS_DEC, NUM_OUTPUTS]) 91 | b_out = tf.get_variable('b_out', [NUM_OUTPUTS]) 92 | 93 | output_projection = [W_out, b_out] 94 | 95 | X_embedded = tf.gather(X_embeddings, Xs, name='embed_X') 96 | t_embedded = tf.gather(t_embeddings, ts_in, name='embed_t') 97 | 98 | # forward encoding 99 | enc_cell = tf.nn.rnn_cell.GRUCell(NUM_UNITS_ENC)#python.ops.rnn_cell.GRUCell 100 | _, enc_state = rnn.dynamic_rnn(cell=enc_cell, inputs=X_embedded, dtype=tf.float32, 101 | sequence_length=X_len) 102 | # use below incase TF's makes issues 103 | #enc_state, _ = tf_utils.encoder(X_embedded, X_len, 'encoder', NUM_UNITS_ENC) 104 | # 105 | #enc_state = tf.concat(1, [enc_state, enc_state]) 106 | 107 | # decoding 108 | # note that we are using a wrapper for decoding here, this wrapper is hardcoded to only use GRU 109 | # check out tf_utils to see how you make your own decoder 110 | 111 | dec_cell = tf.nn.rnn_cell.GRUCell(NUM_UNITS_DEC) 112 | 113 | def decoder_fn_wrapper(inputs_fn): 114 | def decoder_fn(self): 115 | def loop_fn(time, cell_output, cell_state, loop_state): 116 | elements_finished = (time >= self.sequence_length) #TODO handle seq_len=None 117 | # get s_t, y_t 118 | emit_output = cell_output 119 | if cell_output is None: 120 | next_cell_state = self.state 121 | else: 122 | next_cell_state = cell_state 123 | # get x_{t+1} 124 | next_input, elements_finished = inputs_fn(self, time, next_cell_state, elements_finished) 125 | # get loop_state 126 | next_loop_state = loop_state 127 | return (elements_finished, next_input, next_cell_state, 128 | emit_output, next_loop_state) 129 | return loop_fn 130 | return decoder_fn 131 | 132 | 133 | def inputs_fn_train(self, time, state, elements_finished): 134 | finished = math_ops.reduce_all(elements_finished) 135 | return control_flow_ops.cond( 136 | finished, 137 | lambda: array_ops.zeros([self.batch_size, self.input_depth], dtype=self.dtype), 138 | lambda: self.inputs_ta.read(time)), elements_finished 139 | 140 | def inputs_fn_eval_wrapper(embeddings, eos_symbol, output_fn): 141 | def inputs_fn_eval(self, time, state, elements_finished): 142 | finished = math_ops.reduce_all(elements_finished) 143 | next_input = control_flow_ops.cond( 144 | finished, 145 | # zero state handling 146 | lambda: array_ops.zeros([self.batch_size, self.input_depth], 147 | dtype=self.dtype), 148 | lambda: control_flow_ops.cond(math_ops.greater(time, 0), 149 | # get embedding 150 | lambda: tf.gather(embeddings, tf.argmax(output_fn(self, state), 1)), # Gather max prediction. 151 | # read at eos-tag 152 | lambda: self.inputs_ta.read(0))) # Read tag 153 | print next_input.get_shape() 154 | return next_input, elements_finished 155 | return inputs_fn_eval 156 | 157 | def cool_inputs_fn_eval_wrapper(embeddings, eos): 158 | def inputs_fn_eval(self, time, state, elements_finished): 159 | next_input_id = control_flow_ops.cond(math_ops.greater(time, 0), 160 | lambda: tf.argmax(self.output_fn(self, state), 1), 161 | lambda: tf.ones([self.batch_size], dtype=tf.int64) * eos) 162 | # fetching embedding 163 | embedding = tf.gather(embeddings, next_input_id) 164 | # if time != 0, check if embedding is eos and update elements_finished 165 | elements_finished = control_flow_ops.cond(math_ops.greater(time, 0), 166 | lambda: math_ops.logical_or(elements_finished, 167 | next_input_id == eos), 168 | lambda: elements_finished) 169 | print embedding.get_shape() 170 | return embedding, elements_finished 171 | return inputs_fn_eval 172 | 173 | 174 | print(t_embedded) 175 | with vs.variable_scope("decoding") as varscope: 176 | output_fn = lambda self, x: tf.matmul(x, W_out) + b_out 177 | dec_out = rnn_decoder(cell=dec_cell, 178 | decoder_fn=decoder_fn_wrapper(inputs_fn_train), 179 | inputs=t_embedded, 180 | initial_state=enc_state, 181 | sequence_length=t_len).run() 182 | varscope.reuse_variables() 183 | inputs_fn_eval = inputs_fn_eval_wrapper(t_embeddings, data_generator.eos_symbol, output_fn) 184 | valid_dec_out = rnn_decoder(cell=dec_cell, 185 | decoder_fn=decoder_fn_wrapper(inputs_fn_eval), 186 | inputs=t_embedded, 187 | initial_state=enc_state, 188 | output_fn=output_fn, 189 | sequence_length=t_len).run() 190 | # reshaping to have [batch_size*seqlen, num_units] 191 | out_tensor = tf.reshape(dec_out, [-1, NUM_UNITS_DEC]) 192 | valid_out_tensor = tf.reshape(valid_dec_out, [-1, NUM_UNITS_DEC]) 193 | # computing output 194 | out_tensor = output_fn(None, out_tensor) 195 | valid_out_tensor = output_fn(None, valid_out_tensor) 196 | # reshaping back to sequence 197 | b_size = tf.shape(X_len)[0] # use a variable we know has batch_size in [0] 198 | seq_len = tf.shape(t_embedded)[1] # variable we know has sequence length in [1] 199 | num_out = tf.constant(NUM_OUTPUTS) # casting NUM_OUTPUTS to a tensor variable 200 | out_shape = tf.concat(0, [tf.expand_dims(b_size, 0), 201 | tf.expand_dims(seq_len, 0), 202 | tf.expand_dims(num_out, 0)]) 203 | out_tensor = tf.reshape(out_tensor, out_shape) 204 | valid_out_tensor = tf.reshape(valid_out_tensor, out_shape) 205 | # handling shape loss 206 | #out_tensor.set_shape([None, None, NUM_OUTPUTS]) 207 | y = out_tensor 208 | y_valid = valid_out_tensor 209 | -------------------------------------------------------------------------------- /old/thesis-talk.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/old/thesis-talk.pdf -------------------------------------------------------------------------------- /old/thesis_article.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/old/thesis_article.pdf -------------------------------------------------------------------------------- /resume_latex_2021-10-10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrojo/me/8d3985bca5502799461c781ad6b50971b512dbaa/resume_latex_2021-10-10.zip --------------------------------------------------------------------------------