LingxB

3

votes
1

answer
27

views

Loop over tensor dimension 0 (NoneType) with second tensor values

I have a tensor a, I'd like to loop over the rows and index values based on another tensor l. i.e. l suggests the length of the vector I need. sess = tf.InteractiveSession() a = tf.constant(np.random.rand(3,4)) # shape=(3,4) a.eval() Out: array([[0.35879311, 0.35347166, 0.31525201, 0.24089784], [0.4...
LingxB
1

votes
1

answer
6.4k

views

Keras Multi-inputs AttributeError: 'NoneType' object has no attribute 'inbound_nodes'

I'm trying to build a model as ilustrated in below diagram. The idea is to take more than one categorical features (one-hot vectors) and embed them separately, then combine those embedded vectors with a 3D tensor for a LSTM. With following code in Keras2.0.2, when creating the Model() object with mu...
LingxB
1

votes
5

answer
50

views

Combining Keys in Dictionary into tuples in a list

I'm looking for a solution to search keys in a dictionary according to a list as value, and later append the keys to a list of tuples. I'm able to search for the correct keys but can't find a way to build the list I'm expecting. Appreciate for kind help. As below, I'd like to find all keys in d whic...
LingxB
3

votes
4

answer
1k

views

Python: Regular Expression not working properly

I'm using following regex, it suppose to find the string 'U.S.A.', but it only gets 'A.', is anyone know what's wrong? #INPUT import re text = 'That U.S.A. poster-print costs $12.40...' print re.findall(r'([A-Z]\.)+', text) #OUTPUT ['A.'] Expected Output: ['U.S.A.'] I'm following the NLTK Book, Chap...
LingxB
1

votes
1

answer
193

views

XGBRegressor: change random_state no effect

the xgboost.XGBRegressor seems to produce the same results despite the fact a new random seed is given. According to the xgboost documentation xgboost.XGBRegressor: seed : int Random number seed. (Deprecated, please use random_state) random_state : int Random number seed. (replaces seed) random_sta...
LingxB
1

votes
1

answer
809

views

Octave Replace elements in a vector under certain circumstances

I have two vectors as below: p = zeros(5,1); hx = [0.1; 0.3; 0.7; 0.9; 0.2]; the task is to replace elements in p from 0 to 1 if elements in hx >=0.5. Expeted output: p = 0 0 1 1 0 It can be achieved by below code, what I don't understand is: as pos = find(hx >= 0.5); gives a 2D vector, how to under...
LingxB
3

votes
1

answer
1.8k

views

How does Fine-tuning Word Embeddings work?

I've been reading some NLP with Deep Learning papers and found Fine-tuning seems to be a simple but yet confusing concept. There's been the same question asked here but still not quite clear. Fine-tuning pre-trained word embeddings to task-specific word embeddings as mentioned in papers like Y. Kim...
LingxB
-1

votes
1

answer
921

views

Print list items in one line along with other things [duplicate]

This question already has an answer here: Concatenate item in list to strings 4 answers I have a list and I'd like to print every item in that list along with other information in one line. Any advise will be appreciated. l = ['absolute', 'nicest'] print 'P', l, 'Score' The output will be: P ['abso...
LingxB