GUI and Desktop Applications
int64
0
1
A_Id
int64
5.3k
72.5M
Networking and APIs
int64
0
1
Python Basics and Environment
int64
0
1
Other
int64
0
1
Database and SQL
int64
0
1
Available Count
int64
1
13
is_accepted
bool
2 classes
Q_Score
int64
0
1.72k
CreationDate
stringlengths
23
23
Users Score
int64
-11
327
AnswerCount
int64
1
31
System Administration and DevOps
int64
0
1
Title
stringlengths
15
149
Q_Id
int64
5.14k
60M
Score
float64
-1
1.2
Tags
stringlengths
6
90
Answer
stringlengths
18
5.54k
Question
stringlengths
49
9.42k
Web Development
int64
0
1
Data Science and Machine Learning
int64
1
1
ViewCount
int64
7
3.27M
0
59,307,014
0
0
1
0
1
false
3
2017-11-17T08:33:00.000
0
2
0
generalized ordered logit in R or python
47,346,321
0
python,r,logistic-regression
Try the 'VGAM' package. There is a function called vglm. example: vglm(Var2~factor(Var1),cumulative(parallel = F),data) generalized order model cumulative(parallel=T) will perform a proportional odds model. parallel=F is the default.
I would like to fit a generalized ordered logit model to some data I have. I first tried to use the ordered logit model using the MASS package from R, but it seems that the proportional odds assumption is violated by the data. Indeed, not all independent variables do exert the same effect across all categories of the dependent variable. Hence I am a bit blocked. I say that I could use the generalized ordered logit model instead, but could not find how to use it. Indeed, I can not find any package on either R or python that coud help me on that. If someone has any hints on packages I could use, it would be of great help! Thank you very much!
0
1
1,939
0
47,747,060
0
0
0
0
1
true
1
2017-11-17T11:35:00.000
0
1
0
_pickle.UnpicklingError: invalid load key, 'xff'
47,349,740
1.2
python,io,stream
Actually in my case this was appearing due to unexpectedly something else was also getting in the data after getting pickled and before being sent to other end. So I was trying to unpickle some garbage data. Thats why this contained some unidentified character.
I am creating a tuple of two objects and pickling them. And when I try to unpickle them on the server side after passing it through sockets. It gives the above mentioned error.
0
1
862
0
47,353,749
0
0
0
0
1
true
0
2017-11-17T13:20:00.000
1
1
0
how to obtain predictive posteriors in pystan?
47,351,601
1.2
python,r,stan
As far as I know, they are not any Python libraries that do what the brms and rstanarm R packages do, i.e. come with precompiled Stan models that allow users to draw from the predictive distribution in the high-level language. There are things like prophet and survivalstan but those are for a pretty niche set of models.
I'm trying to move from using stan in R (I've mainly used the brms package) to pystan, but having trouble locating any methods in pystan that will give me predictive posterior distributions for new data. In R, I've been using brms::posterior_linpred() to do this. Does anyone know if this is possible in pystan? If not, can it be bolted on without too much problem?
0
1
174
0
47,355,283
0
0
0
0
1
false
0
2017-11-17T14:55:00.000
0
1
0
Is the validation set used for anything besides monitoring progress on the Tensorflow for poets google code lab's project?
47,353,479
0
python,machine-learning,tensorflow,deep-learning,data-science
Very briefly, you have three sets of data: training, testing, and validation. These inputs should be distinct; any duplication between data sets will reduce some desirable aspect of your final model. Training data is used just the way you think: these are the inputs that are matched with the expected outputs (after filtering through your model). The model weights are adjusted until you've converged at the greatest accuracy you can manage. Testing data is used during training to determine when training is done. If the testing accuracy is still dropping, then your model is still learning things; when it starts to rise, you're over-fitting. Validation data is the final check on whether your training phase got to a useful point. This data set is entirely independent of the previous two, as is representative of not-previously-seen, real-world input. The short answer is no. If you fold your testing and validation data into your training set (which is what I think you're trying to ask) and re-train the model, you've changed the training conditions, and you have no evidence that the resulting training is still valid. How do you know ho many epochs you need to train with this larger data set? When you're ready to deploy the trained model, how do you know your new accuracy?
I would like to know if the validation set influences in any way the training of the network, or if it's sole purpose is to monitor the training progress (with the tensorflow for poets project in question). If doesn't, is it okay/good-practice to reduce the validation and training sets to zero once I know the accuracy for my dataset? So in that way I can get a model trained with the most amount of data I can provide.
0
1
31
0
47,420,745
0
0
0
0
1
true
3
2017-11-18T01:31:00.000
0
2
0
Dask: subset (or drop) rows from Dataframe by index
47,361,570
1.2
python,dask
I'm not sure this is the "best" way, but here's how I ended up doing it: Create a Pandas DataFrame with the index be the series of index keys I want to keep (e.g., pd.DataFrame(index=overlap_list)) Inner join the Dask Dataframe
I'd like to take a subset of rows of a Dask dataframe based on a set of index keys. (Specifically, I want to find rows of ddf1 whose index is not in the index of ddf2.) Both cache.drop([overlap_list]) and diff = cache[should_keep_bool_array] either throw a NotImplementedException or otherwise don't work. What is the best way to do this?
0
1
1,328
0
52,067,484
0
0
0
0
1
false
1
2017-11-18T14:31:00.000
0
1
0
Multi-line text dataset in Tensorflow
47,367,180
0
python,tensorflow,tensorflow-datasets
You can try two options: Write a generator and then use Dataset.from_generator: In your generator you can read your file line by line, append to your example while doing that and then yield when you encounter your custom delimiter. First parse your file, create tf.train.SequenceExample with multiple lines and then store your dataset as a TFRecordDataset (more cumbersome option in my opinion)
tf.data.* has dataset classes. There is a TextLineDataset, but what I need is one for multiline text (between start/end tokens). Is there a way to use a different line-break delimiter for tf.data.TextLineDataset? I am an experienced developer, but a python neophyte. I can read but my writing is limited. I am bending an existing Tensorflow NMT tutorial to my own dataset. Most TFRecord tutorials involve jpgs or other structured data.
0
1
805
0
57,801,832
0
0
0
0
1
false
24
2017-11-18T16:24:00.000
14
2
0
Pandas read csv file with float values results in weird rounding and decimal digits
47,368,296
1
python,pandas,csv,floating-point,rounding
I realise this is an old question, but maybe this will help someone else: I had a similar problem, but couldn't quite use the same solution. Unfortunately the float_precision option only exists when using the C engine and not with the python engine. So if you have to use the python engine for some other reason (for example because the C engine can't deal with regex literals as deliminators), this little "trick" worked for me: In the pd.read_csv arguments, define dtype='str' and then convert your dataframe to whatever dtype you want, e.g. df = df.astype('float64') . Bit of a hack, but it seems to work. If anyone has any suggestions on how to solve this in a better way, let me know.
I have a csv file containing numerical values such as 1524.449677. There are always exactly 6 decimal places. When I import the csv file (and other columns) via pandas read_csv, the column automatically gets the datatype object. My issue is that the values are shown as 2470.6911370000003 which actually should be 2470.691137. Or the value 2484.30691 is shown as 2484.3069100000002. This seems to be a datatype issue in some way. I tried to explicitly provide the data type when importing via read_csv by giving the dtype argument as {'columnname': np.float64}. Still the issue did not go away. How can I get the values imported and shown exactly as they are in the source csv file?
0
1
30,458
0
47,400,198
0
0
0
0
1
true
0
2017-11-19T23:58:00.000
0
1
0
How do I use the output of one RNN applied to slices as input of the next?
47,383,336
1.2
python,tensorflow,tflearn
I think you don't need map_fn, you need tf.dynamic_rnn instead. It takes an RNN cell (so it knows what's the output and what's the state) and returns the concatenated outputs and concatenated states.
Suppose I have training data X, Y where X has shape (n,m,p) I want to set up a neural network which applies a RNN (followed by a dense layer) given by f to each i-slice (i,a,b) and outputs f(m,x) which has shape (p') then concatenates all the output slices (presumably using tf.map_fn(f,X)) to form a vector of dimension (n,p') then runs the next neural network on (n,p'). Essentially something similar to: X' = tf.map_fn(f,X) Y= g(X') I am having difficulty getting my head around how to prepare my training data, which shape should X, X' (and later Z) should be. Further more what if I wanted to merge X' with another dataset, say Z? Y = g(X' concat Z)
0
1
39
0
47,400,793
0
0
0
0
1
false
0
2017-11-20T10:37:00.000
0
1
0
Obtain distance matrix from scipy `linkage` output
47,390,019
0
python,scipy,cluster-analysis,hierarchical-clustering,linkage
The linkage output clearly does not contain the entire distance matrix. The output is (n-1 x 4), but the entire distance matrix is much larger: n*(n-1)/2. The contents of the matrix are well described in the Scopus documentation.
I would like to reconstruct a condensed distance matrix from the linkage output when using scipy.cluster.hierarchy.linkage. The input is an m by n observation matrix. I understand therefore, that the distances are computed internally and then finally output in the linkage table. Does anybody know of a solution to obtain the condensed distance matrix from the linkage output?
0
1
284
0
47,405,311
0
0
0
0
1
false
1
2017-11-21T03:52:00.000
0
3
0
Find indices of raster cells that intersect with a polygon
47,404,898
0
python,gdal,ogr
if you want to do this manually you'll need to test each cell for: Square v Polygon intersection and Square v Line intersection. If you treat each square as a 2d point this becomes easier - it's now a Point v Polygon problem. Check in Game Dev forums for collision algorithms. Good luck!
I want to get a list of indices (row,col) for all raster cells that fall within or are intersected by a polygon feature. Looking for a solution in python, ideally with gdal/ogr modules. Other posts have suggested rasterizing the polygon, but I would rather have direct access to the cell indices if possible.
0
1
3,761
0
47,534,280
0
0
0
0
1
true
1
2017-11-21T15:45:00.000
0
1
0
Is it possible to optimize a Tensorflow MLP with the averaged loss after n iterations instead of every iteration?
47,417,060
1.2
python,tensorflow,neural-network,perceptron,multi-layer
Apparently, feeding an array [x,n] (where x is the number of inputs, I would otherwise have to feed seperatley in each iteration and n is the amount of sequential pixels) to my network and then optimizing the loss computed for this input, is exactly what I was looking for.
The input of my network is n sequential pixels of a NxN image (where n is small compared to N) and the output is 1 pixel. The loss is defined as the squared difference between the ouput and the desired output. I want to use the optimizer on the average loss after iterating over the whole image. But if I try to collect the loss in a list and average those losses after all the iterations are done, feeding this to my optimizer, causes an error because Tensorflow does not know where this loss comes from since it is not on the computational graph.
0
1
42
0
47,422,098
0
0
0
0
1
false
2
2017-11-21T20:13:00.000
0
3
0
pandas: split dataframe into multiple csvs
47,421,880
0
python-3.x,pandas
iterating over iloc's arguments will do the trick.
I have a large file, imported into a single dataframe in Pandas. I'm using pandas to split up a file into many segments, by the number of rows in the dataframe. eg: 10 rows: file 1 gets [0:4] file 2 gets [5:9] Is there a way to do this without having to create more dataframes?
0
1
8,708
0
59,068,008
0
0
0
0
1
false
20
2017-11-22T02:57:00.000
1
4
0
python del vs pandas drop
47,426,089
0.049958
python,python-3.x,pandas
In drop method using "inplace=False" you have option to create Subset DF and keep un-touch the original DF, But in del I believe this option is not available.
I know it might be old debate, but out of pandas.drop and python del function which is better in terms of performance over large dataset? I am learning machine learning using python 3 and not sure which one to use. My data is in pandas data frame format. But python del function is in built-in function for python.
0
1
10,359
0
47,440,890
0
1
0
0
1
false
1
2017-11-22T06:32:00.000
5
1
0
How to save installations across sessions?
47,428,195
0.761594
python-2.7,session,google-colaboratory
VMs time out after a period of inactivity, so you'll want to structure your notebooks to install custom dependencies if needed. A typical pattern is to have a cell at the top of your notebook that executes apt and pip install commands as needed. In the case of opencv, that would look something like: !apt install -y -qq libsm6 libxext6 && pip install -q -U opencv-python (Takes ~7 seconds for me on a fresh VM.)
In Colaboratory, is there a way to save library installations across sessions? If so how, can I do that? I'd like to learn more about Colaboratory session management in general. Currently, everytime I have to import, for e.g. a cv2 module(as this is not available by default), I need to reinstall the module with !pip install opencv-python along with it's dependencies that provide for shared objects, through a !apt=-get package-name.
0
1
309
0
47,432,646
0
0
0
0
1
true
2
2017-11-22T10:00:00.000
2
1
0
Does cross_val_score take sequential samples or random samples?
47,431,661
1.2
python,machine-learning,scikit-learn,cross-validation
This depends on what you specify in the cv parameter. If the independent variable is binary or multiclass it will use StratifiedKFold, else it will use KFold. You can also override the options by specifying a function (sklearn or otherwise) to perform the splits. The KFold function will divide the data into sequential folds. If you want it to do a random split, you can set the shuffle parameter to True. If you want to fix the random shuffle you can set a value for the random_state. If you do not, it will take a random value and the folds will be different every time you run the function. For StratifiedKFold, it will split the data while attempting to keep the same ratio of classes of the dependent variable in each split. Because of this, there can be slight changes every time you call the function. i.e. It will not be sequential by default.
In this: cross_val_score(GaussianNB(),features,target, cv=10) Are we splitting the data randomly into 10 or is it done sequentially?
0
1
992
0
47,444,089
0
0
0
0
1
true
1
2017-11-22T21:20:00.000
2
1
0
How to create a conv layer where the filter doesn't move across one dimension
47,444,039
1.2
python,tensorflow,convolution
Yes, you could do it that way. Another is to use the stride parameter to specify the stride in each dimension. You can set the other dimension's stride to 0. stride=(1, 0) is the proper syntax, I think.
Put another way I want the filter to cover the image across one dimension and only move in the other direction. If I have an input with shape (ignoring batch size and number of input channels) (h, w), I want to have a filter to have shape (x, w) where x<h. Would creating a filter with shape (x, w) and using padding of 'VALID' be the correct thing to do (the idea being VALID will force that the filter is only convolved across the image when the filter 'fits' across the image in the width dimension)? Might there be another, better way to do this?
0
1
20
0
47,455,441
0
0
0
0
1
true
1
2017-11-23T12:11:00.000
0
1
0
Weird behavior with datetime: error: time data '0' does not match format '%d%b%Y:%H:%M:%S'
47,455,323
1.2
python,pandas,python-datetime
As pointed by jezrael and EdChum, i have bd data in my column. errors='coerce' option solved this problem.
I know this has been asked 1000 times before but what i am experiencing is really weird and I cant troubleshoot it. I have a date column structured like this: 24JUN2017:14:46:57 I use: pd.to_datetime('24JUN2017:14:46:57', format="%d%b%Y:%H:%M:%S") and it works fine. But when I try to input the whole column: pd.to_datetime(df['date_column'], format="%d%b%Y:%H:%M:%S") I get the error of the title. Anyone knows why I might be experiencing this? ps:I have checked for any empty spaces and there are none
0
1
111
0
47,459,041
0
0
0
0
1
false
0
2017-11-23T12:46:00.000
0
1
0
conversion of job responsibilites and requirements from job descriptions to skillset Using Nlp
47,455,914
0
python,nlp,deep-learning,nltk
Use POS tagging / Parse Trees to take the corpus of job responsibility sentences that you have accumulated and split it into some broad categories. (e.g. sentences that start out with a bunch of comma-separated verbs, sentences that have a single verb but are in the past tense (i.e. requiring the person to have some specific type of experience), etc). Now try to create a transformation rule for each of those parts. The rule for the sentence you put above might be to prefix the sentence with the word "Can". Some rules might require to change the tense of some verb, convert some noun from singular to plural, swap the order of some parts of the sentence, etc. All these things should be doable using standard NLP tools.
I am working on a NLP problem of rewriting job responsibilities and requirements to skill sets ready to be mentioned in the resume. Example: 1:responsibility: "Train, supervise, motivate and develop sales personnel to attain or exceed their sales territory sales goals;" 1:skill: "Have provided training,guidance and motivation to sales representatives to achieve or exceed their sales area and target." I have tried to do this using paraphrasing techniques,but the narration of sentence and some words are not appropriate to be mentioned in resume. Any help and guidance will be appreciable. Thanks
0
1
53
0
47,469,592
0
0
0
0
1
false
0
2017-11-24T08:56:00.000
0
1
0
Animating modes in openmodal: roving type
47,469,591
0
python,open-source
in animation tab try a right click on model and under "roving type" select "response roved".
I am asking this for mgx4: I imported a .uff file containing FRF from Experimental Modal Analysis (EMA). I generated the mesh (geometry) of the tested structure with lines and triangle surfaces. I succeed to realize the analysis and extract eigen frequencies and modal damping. What I am still unable to do is to animate the geometry according to eigen shapes as a function of eigen frequencies. When I am on the tab "Measurement" on the tab menu "ANIMATION" and I put the frequency cursor on one peak of the FRF and I click on "Play", I can just see one node moving. I would like to observe all the nodes moving in order to identify the eigen shape of the mode observed. Do you please have an idea on how to do that? Thank you for your help!
0
1
45
0
63,786,602
0
0
0
0
1
false
0
2017-11-24T14:22:00.000
-1
1
0
distance calculation between camera and depth pixel?
47,475,206
-0.197375
python,opencv,object,depth
The content of my research is the same as yours, but I have a problem now. I use stereocalibrate() to calibrate the binocular camera, and found that the obtained translation matrix is very different from the actual baseline distance. In addition, the parameters used in stereocalibrate() are obtained by calibrating the two cameras with calibrate().
I need to calculate distance from camera to depth image pixel. I searched through internet but I found stereo image related info and code example where I need info for depth image. Here, I defined depth image in gray scale(0-255) and I defined a particular value( let range defined 0 pixel value is equal to 5m and 255 pixel value is equal to 500m in gray scale). camera's intrinsic (focal length, image sensor format) and extrinsic (rotation and transition matrix) is given. I need to calculate distance from different camera orientation and rotation. I want to do it using opencv python. Is there any specific documentation and code example regarding this? Or any further info is necessary to find this.
0
1
569
0
48,661,572
0
1
0
0
2
false
3
2017-11-26T14:17:00.000
4
2
0
Module 'matplotlib' has no attribute 'colors'
47,497,097
0.379949
python-3.x,matplotlib,anaconda
The notebook needs to be restarted for the new installations to take effect.
I am running an Anaconda installation of Python3 64bit on Windows. I have no idea how to put those words in a proper sentence, but I hope it gives enough information. I am taking an Udacity course which wants me to run %matplotlib inline. This gives the following error: AttributeError: module 'matplotlib' has no attribute 'colors' I get the same error when I run from matplotlib import pylab, but i get no error from import matplotlib. I installed matplotlib as follows: conda install -n tensorflow -c conda-forge matplotlib. How do I solve this error? Kind regards Per request: conda list gives matplotlib 2.1.0 py36_1 conda-forge and a list of other modules.
0
1
15,407
0
53,349,221
0
1
0
0
2
false
3
2017-11-26T14:17:00.000
1
2
0
Module 'matplotlib' has no attribute 'colors'
47,497,097
0.099668
python-3.x,matplotlib,anaconda
You just need to upgrade matplotlib. pip3 install -U matplotlib
I am running an Anaconda installation of Python3 64bit on Windows. I have no idea how to put those words in a proper sentence, but I hope it gives enough information. I am taking an Udacity course which wants me to run %matplotlib inline. This gives the following error: AttributeError: module 'matplotlib' has no attribute 'colors' I get the same error when I run from matplotlib import pylab, but i get no error from import matplotlib. I installed matplotlib as follows: conda install -n tensorflow -c conda-forge matplotlib. How do I solve this error? Kind regards Per request: conda list gives matplotlib 2.1.0 py36_1 conda-forge and a list of other modules.
0
1
15,407
0
47,608,446
0
0
0
0
1
false
3
2017-11-26T15:09:00.000
1
3
0
scipy.optimize.minimize('SLSQP') too slow when given 2000 dim variable
47,497,552
0.066568
python,optimization,nonlinear-optimization
Surprisingly, I found a relatively ok solution using an optimizer from for a deep learning framework, Tensorflow, using basic gradient descent (actually RMSProp, gradient descent with momentum) after I changed the cost function to include the inequality constraint and the bounding constraints as penalties (I suppose this is same as lagrange method). It trains super fast and converges quickly with proper lambda parameters on the constraint penalties. I didn't even have to rewrite the jacobians as TF takes care of that without much speed impact apparently. Before that, I managed to get NLOPT to work and it is much faster than scipy/SLSQP but still slow on higher dimensions. Also NLOPT/AUGLANG is super fast but converges poorly. This said, at 20k variables, it is stillslow. Partly due to memory swapping and the cost function being at least O(n^2) from the pair-wise euclidean distance (I use (x-x.t)^2+(y-y.t)^2 with broadcasting). So still not optimal.
I have a non-lenear optimization problem with a constraint and upper/lower bounds, so with scipy I have to use SLSQP. The problem is clearly not convex. I got the jacobian fo both the objective and constraint functions to work correctly (results are good/fast up to 300 input vector). All functions are vectorized and tuned to run very fast. The problem is that using 1000+ input vector takes ages though I can see the minimizer is not calling my functions a lot (objective/constraint/gradients) and seems to spend most of its processing time internally. I read somewhere perf of SLSQP is O(n^3). Is there a better/faster SLSQP implementation or another method for this type of problem for python ? I tried nlopt and somehow returns wrong results given the exact same functions I use in scipy (with a wrapper to adapt to its method signature). I also failed to use ipopt with pyipopt package, cannot get working ipopt binaries to work with the python wrapper. UPDATE: if it helps, my input variable is basically a vector of (x,y) tuples or points in 2D surface representing coordinates. With 1000 points, I end up with a 2000 dim input vector. The function I want to optimize calculates optimum position of the points between each other taking into consideration their relationships and other constraints. So the problem is not sparse. Thanks...
0
1
8,691
0
55,925,583
0
1
0
0
1
true
0
2017-11-26T21:37:00.000
0
1
0
Best way to make data loaded in main() an implicit argument of a function in Python
47,501,275
1.2
python,main,functools
I ended up going with my proposed answer: define those functions in utils.py with the data as explicit parameters, and then use functools.partial before generating the equations to make them implicit and with that codebase having been in production for over a year, it seems reasonable enough to me.
My main function loads a largish dataframe from a csv supplied by the user (along with several other data objects), and then instantiates an object that forms a bunch of equations as part of a mathematical programming problem. Many of the equations' components are returned by calls to about 5 helper functions that I define in a utils file (most importantly, outside of the class that stores the optimization problem). These helper functions make reference to the data loaded in main, but I want their calls to show up in the equations as parameterized only by a time index t (not by the dataframe), for readability. Is the best way to accomplish this to define those functions in utils.py with the data as explicit parameters, and then use functools.partial before generating the equations to make them implicit? This seems like a verbose approach to me, but the other options seem worse: to define the helper functions inside of main, or to give up on the idea of a main function loading the data, which basically means giving up on having a main function. And possibly having confusing circular imports.
0
1
36
0
47,516,794
0
0
0
0
1
true
0
2017-11-27T16:32:00.000
0
3
0
How to index a pandas data frame starting at n?
47,515,644
1.2
python,pandas,csv,dataframe,indexing
you may just reset the index at the end or define a local variable and use it in `arange' function. update the variable with the numbers of rows for each file you read.
Is it possible to start the index from n in a pandas dataframe? I have some datasets saved as csv files, and would like to add the column index with the row number starting from where the last row number ended in the previous file. For example, for the first file I'm using the following code which works fine, so I got an output csv file with rows starting at 1 to 1048574, as expected: yellow_jan['index'] = range(1, len(yellow_jan) + 1) I would like to do same for the yellow_feb file, but starting the row index at 1048575 and so on. Appreciate any help!
0
1
1,626
0
47,526,928
0
0
0
0
1
false
1
2017-11-28T07:23:00.000
0
2
0
How to quickly check if a value exists in pandas DataFrame index?
47,526,059
0
python,pandas,dataframe
Another way could be. a=time.time() if value in set(dataframe.index) b=time.time() timetaken=b-a
When I update the dataframe, I should check if the value exists in the dataframe index, but I want to know which way is faster, thanks! 1. if value in set(dataframe.index) 2. if value in dataframe.index
0
1
2,481
0
47,536,805
0
0
0
0
1
false
3
2017-11-28T14:25:00.000
5
1
0
How can I choose eps and minPts (two parameters for DBSCAN algorithm) for efficient results?
47,533,930
0.761594
python,cluster-analysis,dbscan
The DBSCAN paper suggests to choose minPts based on the dimensionality, and eps based on the elbow in the k-distance graph. In the more recent publication Schubert, E., Sander, J., Ester, M., Kriegel, H. P., & Xu, X. (2017). DBSCAN Revisited, Revisited: Why and How You Should (Still) Use DBSCAN. ACM Transactions on Database Systems (TODS), 42(3), 19. the authors suggest to use a larger minpts for large and noisy data sets, and to adjust epsilon depending on whether you get too large clusters (decrease epsilon) or too much noise (increase epsilon). Clustering requires iterations. That paper was an interesting read, because it shows what can go wrong if you don't look at your data. People are too obsesses with performance metrics, and forget to look at the actual data.
What routine or algorithm should I use to provide eps and minPts parameters to DBSCAN algorithm for efficient results?
0
1
4,405
0
47,536,983
0
0
0
0
1
true
0
2017-11-28T16:10:00.000
0
1
0
Define a custom layer with 2 tensors inputs in Keras
47,536,066
1.2
python,neural-network,keras,layer
Since you don't need it to be trainable, a lambda function will also do. Or you can keep the custom layer as you have it, and set trainable to False. The weights will never be updated for this layer, and whatever you do here will forward propagate to the next layer in the model and as mentioned in the comments, backprop will impact the other layers with weights. So, definitely your model will learn something. I personally recommend using a custom layer, if you decide later to add some learning to this layer and check your results. You cannot do this in a Lambda function. If you add one (kernel), you will have to use in the 'call' method. Your model will throw an error during training otherwise.
I would like to implement a custom layer. The 2 inputs of my custom layer are 2 tensors, which come from 2 seperate 2D convolution layers, is there an example?
0
1
406
0
47,562,880
0
1
0
0
1
true
0
2017-11-29T22:21:00.000
0
3
0
How to compute the product some of parts of two vectors
47,562,817
1.2
python,tensorflow
If it's just that simple do: sum([A[i]*B[i] for i in range(3)]) This sums the products of the first three values with each other. Hope this helps!
How can I compute the product sum of the first three elements of two vectors A = [a1, a2, a3, a4, a5, a6]andB = [b1, b2, b3, b4, b5, b6] (i.e. [a1b1 + a2b2 + a3b3])in python and tensorflow.
0
1
52
0
47,566,035
0
1
0
0
1
true
2
2017-11-30T04:41:00.000
0
1
0
How to change a font size within a plot figure
47,566,009
1.2
python,matplotlib,plot
You may use tick_params function like plt.tick_params(axis='y', which='major', labelsize=10)
This question already has an answer here: How to change the font size on a matplotlib plot
0
1
445
0
47,578,933
0
0
0
0
1
false
0
2017-11-30T17:01:00.000
0
2
0
Python: How to efficiently do operations using different rows of the same column?
47,578,774
0
python,pandas,dataframe
If you have unique date or DaysToReception, you can actually use Map/HashMap where the key will be the date or DaysToReception and the values will be other information which you can store using a list or any other appropriate data structure. This will definitely improve the efficiency. As you pointed out that "number of rows I search the value below depends on the value "DaysToReception", I believe "DaysToReception" will not be unique. In that case, the key to your Map will be the date.
My goal is that by given a value on a row (let's say 3), look for the value of a given column 3 rows below. Currently I am perfoming this using for loops but it is tremendously inefficient. I have read that vectorizing can help to solve this problem but I am not sure how. My data is like this: Date DaysToReception Quantity QuantityAtTheEnd 20/03 3 102 21/03 - 88 22/03 - 57 23/03 5 178 24/03 And I want to obtain: Date DaysToReception Quantity QuantityAtReception 20/03 3 102 178 21/03 - 88 22/03 - 57 23/03 5 178 24/03 ... Thanks for your help!
0
1
19
0
47,585,710
0
0
0
0
1
false
0
2017-12-01T02:13:00.000
0
2
0
Load classifier on Heroku Python
47,585,666
0
python,opencv,heroku,cascade-classifier
I figured it out. All I needed to do was use the os.path.abspath() method to convert the relative path to an absolute path
I am loading a cascade classifier from a file in OpenCV using python. Since the CascadeClassifier() method requires the filename to be the absolute filename, I have to load the absolute filename. However, I am deploying and using it on Heroku and I can't seem to get the absolute path of the file. I've tried using os.getcwd() + '\cascader_file.xml', but that still does not work. I would like to know how to load the classifier on the Heroku deployment
0
1
174
0
47,586,784
0
0
0
0
1
false
0
2017-12-01T04:19:00.000
0
2
0
Vehicle counting based on classification (cars,buses,trucks)
47,586,587
0
python,opencv,image-processing,bounding-box
I have worked on almost similar problem. Easiest way is to train a Haar-cascade on the vehicles of similar size. You will have to train multiple cascades based on the number of categories. Data for the cascade can be downloaded from any used car selling site using some browser plugin. The negative sets pretty much depend on the context in which this solution will be used. This also brings the issue that, if you plan to do this on a busy street, there are going to be many unforeseen scenarios. For example, pedestrian walking in the FoV. Also, FoV needs to be fixed, especially the distance from which objects are observed. Trail and error is the only way to achieve sweet-spot for the thresholds, if any. Now I am going to suggest something outside the scope of the question you asked. Though this is purely image processing based approach, you can turn the problem on its face, and ask a question 'Why' classification is needed? Depending on the use-case, more often than not, it will be possible to train a deep reinforcement learning agent. It will solve the problem without getting into lot of manual work. Let me know in case of a specific issues.
I am currently working on vehicle platooning for which I need to design a code in python opencv for counting the number of vehicles based on the classification.The input is a real time traffic video. The aim is finding an average size "x" for the bounding box and say that for cars its "x", for buses its "3x" and so on.Based on size of "x" or multiples of "x", determine the classification.Is there any possible way I can approach this problem statement?
0
1
1,211
0
47,591,883
0
1
0
0
1
false
0
2017-12-01T10:36:00.000
1
1
0
error for installing COMMIT package in anaconda 3
47,591,513
0.197375
python,anaconda,commit
If you already have the binary downloaded on the folder why you need to run pip install commit That would download and install it again right? Just run pip install . on the folder where you downloaded the package.
I am going to install commit framework (Convex Optimization Modeling for Microstructure Informed Tractography) on anaconda 3. Here I explained the process that I did: 1st, I downloaded commit and then opened an anaconda prompt and went to the location that I downloaded the folder but when I run pip install commit I faced with this error: Could not find a version that satisfies the requirement commit. No matching distribution found for commit. I am grateful for any suggestion to solve this error.
0
1
30
0
47,598,201
0
1
0
0
1
false
0
2017-12-01T11:35:00.000
0
2
0
Cannot load scikit-learn
47,592,516
0
python,import,installation,scikit-learn
Have you tried to import sklearn directly from a Python interpreter ? Also, try to check in your Project Settings that sklearn is recognized as a package of the Python interpreter associated (Settings --> Project --> Project Interpreter)
When I try to import sklearn, I get the following error message: ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden. (In English: The specified module was not found) I'm working on Windows 10, 64-Bit. I'm using Python 3.6.1. (and no other version), Anaconda and PyCharm. I installed scikit-learn using conda install scikit-learn and I can find it in conda list as well as in File | Settings | Project Interpreter with version 0.19.1. I also have numpy 1.13.3 and scipy 1.0.0. I know this error message has been discussed multiple, but none of these discussions could help me ... I tried uninstalling and re-installing numpy, scipy and scikit-learn. I also tried installing scikit-learn using pip. If I randomly try to load other packages, that are in my conda list, they all work perfectly fine, but not scikit-learn. I don't even know where my error is. Can anyone give me a hint in the right direction, or a suggestion what I could try? Thanks!
0
1
606
0
47,685,678
0
0
0
0
2
false
1
2017-12-02T08:53:00.000
0
2
0
YOLO - tensorflow works on cpu but not on gpu
47,606,161
0
python-3.x,tensorflow,darkflow
Problem solved. Changing batch size and image size in config file didn't seem to help as they didn't load correctly. I had to go to defaults.py file and change them up there to lower, to make it possible for my GPU to calculate the steps.
I've used YOLO detection with trained model using my GPU - Nvidia 1060 3Gb, and everything worked fine. Now I am trying to generate my own model, with param --gpu 1.0. Tensorflow can see my gpu, as I can read at start those communicates: "name: GeForce GTX 1060 major: 6 minor: 1 memoryClockRate(GHz): 1.6705" "totalMemory: 3.00GiB freeMemory: 2.43GiB" Anyway, later on, when program loads data, and is trying to start learning i got following error: "failed to allocate 832.51M (872952320 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY" I've checked if it tries to use my other gpu (Intel 630) , but it doesn't. As i run the train process without "--gpu" mode option, it works fine, but slowly. ( I've tried also --gpu 0.8, 0.4 ect.) Any idea how to fix it?
0
1
1,053
0
50,273,011
0
0
0
0
2
false
1
2017-12-02T08:53:00.000
0
2
0
YOLO - tensorflow works on cpu but not on gpu
47,606,161
0
python-3.x,tensorflow,darkflow
Look like your custom model use to much memory and the graphic card cannot support it. You only need to use the --batch option to control the size of memory.
I've used YOLO detection with trained model using my GPU - Nvidia 1060 3Gb, and everything worked fine. Now I am trying to generate my own model, with param --gpu 1.0. Tensorflow can see my gpu, as I can read at start those communicates: "name: GeForce GTX 1060 major: 6 minor: 1 memoryClockRate(GHz): 1.6705" "totalMemory: 3.00GiB freeMemory: 2.43GiB" Anyway, later on, when program loads data, and is trying to start learning i got following error: "failed to allocate 832.51M (872952320 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY" I've checked if it tries to use my other gpu (Intel 630) , but it doesn't. As i run the train process without "--gpu" mode option, it works fine, but slowly. ( I've tried also --gpu 0.8, 0.4 ect.) Any idea how to fix it?
0
1
1,053
0
47,619,440
0
0
0
0
1
false
1
2017-12-03T12:11:00.000
1
1
0
How do I calculate the semantic similarity between two n-grams?
47,618,217
0.197375
python,fasttext,sentence-similarity
Cosine similarity might be useful if you average both word vectors in a bi-gram first. So you want to take the vector for 'his' and 'name', average them into one vector. Then take the vector for 'I' and 'am' and average them into one vector. Finally, calculate cosine similarity for both resulting vectors and it should give you a rough semantic similarity.
I'm trying to calculate the semantic similarity between two bi-grams and I need to use fasttext's pre-trained word vectors to accomplish this task. For ex : The b-grams are python lists of two elements: [his, name] and [I, am] They are two tuples and I need to calculate the similarity between these two tuples by any means necessary. I'm hoping there's a score which can give me a good approximation of similarity. For ex - If there are methods which can tell me that [His, name] is more similar to [I, am] than [An, apple]. Right now I only made use of cosine similarity which does include any semantic similarity.
0
1
567
0
47,719,572
0
0
0
0
1
false
6
2017-12-03T23:27:00.000
-9
3
0
Getting Keras trained model predictions in c#
47,624,488
-1
c#,python,.net,tensorflow,keras
it does not work like that, since you wont even be able to install tensorflow in a C# project. Abandon C# stack and learn framework in python stack instead, ex. if if you need to consume the prediction result in a web app, learn Flask or Django
As title states I'm trying to use my Keras (tf backend) pretrained model for predicitions in c#. What's the best approach? I've tried IronPython but it gave me errors, after search I found it isn't supported. Simply calling python script won't work since target Windows devices won't have python interpreters installed.
0
1
11,563
0
47,655,652
0
1
0
0
1
false
0
2017-12-04T04:18:00.000
0
1
0
can't find tensorflow local in Pycharm project Interpreters
47,626,431
0
python,tensorflow,pycharm,macos-sierra
Click on the python 2.7 that you see. Then after you select you python you will see all the packages that come with it. One of the packages will be Tensorflow.
I am new to tensorflow, OS: Mac 10.13.1 Python: 2.7 tensorflow: 1.4.0(install with pip) I want to use tensorflow from Pycharm for a project, and when I open: "Pycharm" - "Preferences" - "Project Interpreter", There are only two local: 2.7.13/(Library/Frameworks/Python.framework.Versions.2.7/bin/python2.7) /System/Library/Frameworks.Python.framwork.Versions.2,7.bin.python2.7 I can't find tensorflow, what should I do?
0
1
184
0
51,676,877
0
0
0
0
1
true
0
2017-12-05T00:17:00.000
0
1
0
How to get a Queue object from a TensorFlow graph?
47,644,110
1.2
python,tensorflow
I think that as of today that is not possible. However, you can call methods of the queue object by getting them using get_operation_by_name. For example get_operation_by_name("queue_name/enqueue"). You can also make your own Queue object which internally simply calls the corresponding graph operations.
In TensorFlow I have a graph that has in it a string_input_producer that is used in it's input pipeline. I am loading the graph from a checkpoint file, so I do not have access to the original object when it was created. Nonetheless, I need to run the enqueue method of this object. I have tried getting the FIFOQueue object using get_operation_by_name and get_tensor_by_name, which obviously did not work because the queue is neither an operation nor a tensor. Is there any function like the mentioned that would do what I want? (fake e.g. get_queue_by_name) How can I solve my problem otherwise?
0
1
79
0
48,959,163
0
0
0
0
1
false
3
2017-12-05T04:34:00.000
0
2
0
Tensorflow Feature Column for 0 and 1
47,646,159
0
python-3.x,tensorflow
I would recommend tf.feature_column.categorical_column_with_vocabulary_list. I would think you would want to treat the data as categories, rather than as scalars.
For Tensorflow feature columns contain boolean value 0 and 1. Should I be using tf.feature_column.numeric_column or tf.feature_column.categorical_column_with_vocabulary_list?
0
1
1,012
0
48,248,566
0
0
0
0
1
false
16
2017-12-05T14:20:00.000
3
3
0
Oversampling: SMOTE for binary and categorical data in Python
47,655,813
0.197375
python-3.x,imputation
So as per documentation SMOTE doesn't support Categorical data in Python yet, and provides continuous outputs. You can instead employ a workaround where you convert the categorical variables to integers and use SMOTE. Then use np.round(X_train[categorical_variables]) to convert them back to the respective categorical values.
I would like to apply SMOTE to unbalanced dataset which contains binary, categorical and continuous data. Is there a way to apply SMOTE to binary and categorical data?
0
1
22,277
0
47,662,958
0
0
0
0
1
true
22
2017-12-05T20:29:00.000
24
2
0
What is the difference between tensors and sparse tensors?
47,662,143
1.2
python,tensorflow
The difference involves computational speed. If a large tensor has many, many zeroes, it's faster to perform computation by iterating through the non-zero elements. Therefore, you should store the data in a SparseTensor and use the special operations for SparseTensors. The relationship is similar for matrices and sparse matrices. Sparse matrices are common in dynamic systems, and mathematicians have developed many special methods for operating on them.
I am having troubles understanding the meaning and usages for Tensorflow Tensors and Sparse Tensors. According to the documentation Tensor Tensor is a typed multi-dimensional array. For example, you can represent a mini-batch of images as a 4-D array of floating point numbers with dimensions [batch, height, width, channels]. Sparse Tensor TensorFlow represents a sparse tensor as three separate dense tensors: indices, values, and shape. In Python, the three tensors are collected into a SparseTensor class for ease of use. If you have separate indices, values, and shape tensors, wrap them in a SparseTensor object before passing to the ops below. My understandings are Tensors are used for operations, input and output. And Sparse Tensor is just another representation of a Tensor(dense?). Hope someone can further explain the differences, and the use cases for them.
0
1
13,330
0
47,674,949
0
0
0
0
1
true
2
2017-12-06T02:32:00.000
-1
1
0
scikit learn averaged perceptron classifier
47,665,910
1.2
python-2.7,machine-learning,scikit-learn,classification,perceptron
I'm sure someone will correct me if I'm wrong but I do not believe Averaged Perceptron is implemented in sklearn. If I recall correctly, Perceptron in sklearn is simply SGD with certain default parameters. With that said, have you tried good old logistic regression? While it may not be the sexiest algorithm around, it often does provide good results and can serve as a baseline to see if you need to explore more complicated methods.
I am a new learner to machine learning and I want to do a 2-class classification with only a few attributes. I have learned by researching online that two-class averaged perceptron algorithm is good for two-class classification with a linear model. However, I have been reading through the documentation of Scikit-learn, and I am a bit confused if Scikit-learn is providing a averaged perceptron algorithm. I wonder if the sklearn.linear_model.Perceptron class can be implemented as the two-class averaged perceptron algorithm by setting up the parameters correctly. I appreciate it very much for your kind help.
0
1
635
0
48,290,905
0
0
0
0
1
false
0
2017-12-06T17:17:00.000
0
1
0
How can I improve this genetic algorithm for the TSP?
47,679,966
0
python,genetic-algorithm,traveling-salesman,mutation,crossover
A problem in GA's is narrowing your search space too quickly and reaching a local maxima solution. You need to ensure that you are not leading your solution in any way other than in the selection/fitness function. So when you say, why would you take a good solution and then perform a function that will most likely make it a worse solution ,the reason is that you WANT a chance for the solution to take a step back, it will likely need to get worse before it gets better. So really you should remove any judgement logic from your genetic operators, leave this to the selection process. Also, crossover and mutation should be seen as 2 different ways of generating a child individual, you should use one or the other. In practice, this means you have a chance of performing either a mutation of a single parent or a crossover between 2 parents. Usually the mutation chance is only 5% with crossover being used to generate the other 95%. A crossover keeps the genetic information from both parents (children are mirror images), so one child will be worse than the parents and the other better (or both the same). So in this sense with crossover, if there is a change, you will always get a better individual. Mutation on the other hand offers no guarantee of a better individual, yet it exists for the purpose of introducing new data, helping to move the GA from the local maxima scenario. If the mutation fails to improve the individual and makes it worse, then it has less chance of being selected for parenting a child anyway (i.e. you don't need this logic in the mutation operator itself). you select the best one to mutate This is not strictly true, good individuals should have a higher CHANCE of being selected. In here there is a subtle difference that BAD individuals may also be selected for parents. Again this helps reduce the chance of reaching a local maxima solution. This also means that the best individual for a generation could (and often does) actually get worse. To solve this we usually implement 'elitism', whereby the best individual is always copied to the next generation (at it is/undergoing no operations). It would also be beneficial if I could comment on which genetic operators you are using. I have found cycle crossover and inversion mutation to work well in my experience.
This is my genetic algorithm, step by step: Generate two initial population's randomly, and select the fittest tour from both. Perform an ordered crossover, which selects a random portion of the first fit tour and fills in the rest from the second, in order. Mutates this tour by randomly swapping two cities if the tour is only 1.3 times as good as the top 10% tour in the initial population (which I have literally just done by induction, singling out poor tours that are produced) - I would love to change this but can't think of a better way. The mutation is selected from a population of several mutations. Returns the tour produced. The mutation, however is almost ALWAYS worse, if not the same as the crossover. I'd greatly appreciate some help. Thanks!
0
1
469
0
47,710,171
0
0
0
0
1
false
0
2017-12-07T00:42:00.000
0
2
0
How do I finetune ResNet50 Keras to only classify images in 2 classes (cats vs. dogs) instead of all 1000 imagenet classes?
47,685,816
0
python,classification,imagenet
There are several ways of applying Transfer Learning and it's trial & error what works best. However, ImageNet includes multiple types of cats and dogs in its 1000 classes, which is why I would do the following: Add a single Dense layer to your model with 2 outputs Set only the last layer to trainable Retrain the network using only images of cats and dogs This will get solid results rather quickly because you're only training one layer. Meaning, you don't have to backpropagate through the entire network. In addition, your model only has to learn a rather linear mapping from the original cats and dogs subclasses to this binary output.
How do I finetune ResNet50 Keras to only classify images in 2 classes (cats vs. dogs) instead of all 1000 imagenet classes? I used Python and was able to classify random images with ResNet50 and keras with the 1000 ImageNet classes. Now I want to fine tune my code so that it only classifies cats vs. dogs, using the Kaggle images instead of ImageNet. How do I go about doing that?
0
1
544
0
47,720,583
0
0
0
0
1
false
1
2017-12-07T10:20:00.000
1
1
0
XGBoost unreasonable splitting value in nodes
47,692,738
0.197375
python,machine-learning,deep-learning,xgboost
A possible explanation: you have all non-missing values going to the 'text < 4' branch, and all missing values to the other - 'text > 4' - branch. Can you verify?
My xgboost model trained for a regression task in python using the xgboost package version 0.6 is using strange values for splits. Some values used as a splitting criteria are not present in the training dataset at all. Example: - there's a variable 'text' with values in the train set of [Missing,1,2] - yet, a derived splitting criteria of a node in the trained model is 'text < 4' What could be a possible reason of such a split when no such value (-> 4) can be found in the data set?The split does not increase the information gain, since all samples follow one branch after this decision node.
0
1
579
0
47,704,296
0
0
0
0
1
true
2
2017-12-07T21:33:00.000
4
1
0
Why does scipy stats describe does not have median?
47,704,158
1.2
python,scipy,statistics
I cannot speak for the scipy stats.describe people, but the general answer is this: mean, variance, and even kurtosis can be computed in one or two O(n) passes through the data, while median requires an O(n*log(n)) sort.
It might be a naive question but I couldn't find a reasonable answer. Why the median is not included in the return of stats.describe ? Even kurtosis is included but why not median ? Thanks
0
1
573
1
47,741,851
0
0
0
0
1
false
0
2017-12-10T15:16:00.000
0
2
0
Dealing with pixels in real-time using OpenCV
47,740,206
0
python
Want to continue Jakubs great answer: Using C++ or something might be a good idea in some cases. I created a csgo aimbot with opencv, pil, pyautogui and numpy and few other modules, watching sentdex's videos on this subject might give u some idea(link above). There might be a custom module for GPU cv2 tips for py: 1) lower imagegrab resolution. 2) in imagegrab.grab bbox you can give coordinates on which the grabs will happen instead of full screen. 3) grayscale is 0-255 so it will speed up the process, if u know which colors are in this reaction thingy just pass them to grayscale so u know in which colors to respond to.
I just started to study OpenCV with Python and was trying to build my first game bot. My thought is: capture the game window frame by frame and analyze the pixels in some specific locations, if the color of those pixels has changed, then press a key to do some automatic operations. This game needs quick reactions so the FPS is quite important, I have tried the mss and PIL, but the fps in both methods are not enough (30+ with mss and 10+ with PIL's ImageGrab), so I'm wondering if there is any better way to deal with pixels in real-time. Thanks!
0
1
1,166
0
49,182,635
0
1
0
0
1
true
0
2017-12-11T17:00:00.000
1
1
0
Jupyternotebook corrects groupby to groupyouby Python
47,757,753
1.2
python,jupyter
Grammarly was the cause of this. If you use jupyter notebooks and have the grammarly extension. It will cause problems.
I don't know how this happens or why, but I'll be in a jupyter notebook grouping by things and I will very conciously type in dataframe.groupby, write some other code and hit ctrl+ enter and there will be that damn error. Every single time, I will go back and delete the 'groupyouby' and type in groupby. I doubt that anyone has run into this error,and I don't know how long it will be until someone else creates the mess of libraries that I have that resulted in this chinese water tourture like nightmare. I am here, to let you know, that you are not alone. Also if someone has a fix that would be great. I got nothing for you other than that description above.
0
1
39
0
47,775,119
0
0
0
0
1
false
0
2017-12-12T14:09:00.000
0
1
0
Python package installation error for openCV
47,774,652
0
python,opencv
It looks like you have not given a valid file location. The error is saying that it thinks you have given it a whl file to install but it can't find it. I suggest you check you file path again. Make sure it is located at C:\Users\Om and it is called exactly the same as the filename you have put down. It should match opencv_python-3.2.0-cp36-cp36m-win32.whl exactly. Ensure you do not rename the whl file. Correct that and it will attempt an install and if that does not work you will get another error.
C:\Users\Om>pip install opencv_python-3.2.0-cp36-cp36m-win32.whl Requirement 'opencv_python-3.2.0-cp36-cp36m-win32.whl' looks like a filename, but the file does not exist Processing c:\users\om\opencv_python-3.2.0-cp36-cp36m-win32.whl Exception: Traceback (most recent call last): File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\commands\install.py", line 324, in run requirement_set.prepare_files(finder) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\download.py", line 809, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\download.py", line 715, in unpack_file_url unpack_file(from_path, location, content_type, link) File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\utils__init__.py", line 599, in unpack_file flatten=not filename.endswith('.whl') File "c:\users\om\appdata\local\programs\python\python36-32\lib\site-packages\pip\utils__init__.py", line 482, in unzip_file zipfp = open(filename, 'rb') FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Om\opencv_python-3.2.0-cp36-cp36m-win32.whl' what is the problem ?
0
1
266
0
57,437,066
0
0
0
0
2
false
20
2017-12-12T17:34:00.000
2
3
0
Computing TF-IDF on the whole dataset or only on training data?
47,778,403
0.132549
python,machine-learning,scikit-learn,nlp,tf-idf
As we are talking about text data, we have to make sure that the model is trained only on the vocabulary of the training set as when we will deploy a model in real life, it will encounter words that it has never seen before so we have to do the validation on the test set keeping that in mind. We have to make sure that the new words in the test set are not a part of the vocabulary of the model. Hence we have to use fit_transform on the training data and transform on the test data. If you think about doing cross validation, then you can use this logic across all the folds.
In the chapter seven of this book "TensorFlow Machine Learning Cookbook" the author in pre-processing data uses fit_transform function of scikit-learn to get the tfidf features of text for training. The author gives all text data to the function before separating it into train and test. Is it a true action or we must separate data first and then perform fit_transform on train and transform on test?
0
1
12,402
0
55,300,936
0
0
0
0
2
false
20
2017-12-12T17:34:00.000
4
3
0
Computing TF-IDF on the whole dataset or only on training data?
47,778,403
0.26052
python,machine-learning,scikit-learn,nlp,tf-idf
Author gives all text data before separating train and test to function. Is it a true action or we must separate data first then perform tfidf fit_transform on train and transform on test? I would consider this as already leaking some information about the test set into the training set. I tend to always follow the rule that before any pre-processing first thing to do is to separate the data, create a hold-out set.
In the chapter seven of this book "TensorFlow Machine Learning Cookbook" the author in pre-processing data uses fit_transform function of scikit-learn to get the tfidf features of text for training. The author gives all text data to the function before separating it into train and test. Is it a true action or we must separate data first and then perform fit_transform on train and transform on test?
0
1
12,402
0
51,338,424
0
1
0
0
1
false
0
2017-12-12T23:56:00.000
0
2
0
Can import TensorFlow and Keras in Jupyter, even though I have them installed?
47,783,481
0
python,tensorflow,keras,jupyter-notebook
If you are a Windows/Mac user who is working on Jupyter notebook, pip install keras doesn't help you. Instead, try the steps below: In command prompt navigate to the “site packages” directory of your anaconda installed. Now use conda install tensorflow and after conda install keras Restart your Jupyter notebook and run the packages.
I have setup Tensorflow and Keras on Mac OS. I also have Jupyter that came as part of my Anaconda installation. When I try to import Tensoflow or Keras in a Jupyter notebook, I get "a no module named <...>" error. Am I missing a step ?
0
1
661
0
47,800,231
0
1
0
0
1
false
1
2017-12-13T09:50:00.000
-1
1
0
Decrease the debug startup time of the python code in Visual Studio Code
47,789,968
-0.197375
python,pandas,numpy,opencv,visual-studio-code
There's no explicit technique to improving the import time short of using lazy loading, but there are technical considerations which have to be taken into account before going down that route (e.g. some modules simply don't work when loaded lazily).
Is it possible to decrease the debug startup time of the python script in visual studio code? If I a have a lot of import library (like opencv, numpy, pandas and so on) every time i start the debug of the script, pressing the F5 button, the environment wait for seconds to reload them. Is it possible to reduce this time? Thanks.
0
1
80
0
47,808,839
0
0
0
0
1
false
1
2017-12-13T13:37:00.000
0
1
0
OpenCV perspective transform with camera roll and pitch correction
47,794,365
0
python,opencv,graphics,computer-vision
If the camera motion is approximately a rotation about its optical center / lens entrance pupil (for example, pan-tilt-roll on a tripod with the subject distance much larger than the translation of the optical center), then images taken from rotated viewpoints are related by a homography. If you know the 3D rotation (pan/tilt/roll), then you can explicitly compute the homography and apply it to the image. If not, but you have two images upon which you can identify 4 corresponding points or more, then you can estimate the homography directly from those correspondences.
I am performing some perspective transforms on camera images, however in certain cases the roll and pitch of the camera are not zero. In other words, the camera is not level and I would like to be able to correct for this. I have some questions: 1) Can the transformation matrix (from M = cv2.getPerspectiveTransform(...) ) be corrected for the pitch and roll angles? 2) Should I just transform the source points and get a new transformation matrix? Roll seems like a simple enough correction since it's analogous to rotating the image, but how can I get the proper transformation for both roll and pitch?
0
1
715
0
47,806,250
0
0
0
0
1
false
0
2017-12-13T18:13:00.000
0
1
0
Parameter values of Doc2vec for Document Tagging - Gensim
47,799,657
0
python,gensim,doc2vec
Which parameters are best can vary with the quality & size of your training data, and exactly what your downstream goals are. (There's no one set of best-for-everything parameters.) Starting with the gensim defaults is reasonable first guess, or other values you've see someone else having used successfully on a similar dataset/problem. But really you'll need to experiment, ideally by creating an automated evaluation based on some held-back testing set, then meta-optimizing the Doc2Vec parameters by searching over many small adjustments to the parameters for the best ranges/combinations.
my task is to assign tags (descriptive words) to documents or posts from the list of available tags. I'm working with Doc2vec available in Gensim. I read that doc2vec can be used for document tagging. But i could not get the suitable parameter values for this task. Till now, i have tested it by changing value of parameters named 'size' and 'window'. The results i'm getting are too nonsense and also by changing values of these parameters i haven't find any trend in results i.e. at some values results got little bit improved and at some values results fall down. Can anyone suggest what should be suitable parameter values for this task? I found that 'size'(defines size if feature vector) should be large if we have enough training data. But about the rest of parameters, i am not getting sure!
0
1
374
0
54,758,338
0
0
0
0
1
false
4
2017-12-14T01:56:00.000
0
2
1
Distributed Tensorflow: ps/workers hosts on aws ?
47,804,792
0
python,tensorflow,tensorflow-gpu
When a distributed TF code is run on the cluster, other nodes could be accessed through "private ip: port number". But the problem with AWS is that the other nodes can not be easily launched and it needs extra configuration.
I am using distributed Tensorflow on aws using gpus. When I train the model on my local machine, I indicate ps_host/workers_host as something like 'localhost:2225'. What are the ps/workers host I need to use in case of aws?
0
1
186
0
47,820,153
0
0
0
0
1
true
0
2017-12-14T10:19:00.000
2
1
0
Passing functions to CUDA blocks with numba
47,810,891
1.2
python,cuda,numba
The Numba CUDA Python implementation presently doesn't support any sort of function pointer or objects within kernels. So what you would have ambitions to do is not possible.
I am working in python with the numba library and wondered if there is a solution to write a parallel version of a previous work. I have a function f(X, S, F) where X and S are scalar arrays, and F is a list of functions. I am almost sure that passing an array of functions is not possible with numba (and cuda in general?). What would be an alternative solution to this? If there is one. Thanks in advance for your help
0
1
227
0
47,821,531
0
0
0
0
1
true
1
2017-12-14T20:14:00.000
1
1
0
Call scipy.optimize inside pyomo
47,821,346
1.2
python,scipy,pyomo
At the moment (Dec 2017), there is no built-in support for passing a Pyomo model to scipy.optimize. That said, it would not be a very difficult task to write a reasonably general purpose object that could generate the necessary (value, Jacobian, Hessian) evaluation functions to pass to scipy.optimize.minimize().
Can I integrate scipy.optimize.minimize solver with method=SLSQP inside pyomo? Modeling in pyomo is much faster than in scipy but pyomo documentation does not seem to say explicitly if this is feasible.
0
1
588
0
47,830,720
0
0
0
0
1
false
0
2017-12-15T06:44:00.000
0
1
0
Suggestion on LDA
47,827,130
0
python-3.x,nlp,gensim,text-analysis
I have worked on similar lines. This approach can work till 300 such documents. But, taking it to higher scale you need to replicate the approach using spark. Here it goes: 1) Prepare TF-IDF matrix: Represent documents in terms Term Vectors. Why not LDA because you need to supply number of themes first which you don't know first. You can use other methods of representing documents if want to be more sophisticated (better than semantics) try word2Vec, GloVe, Google News Vectors etc. 2) Prepare a Latent Semantic Space from the above TF-IDF. Creation of LSA uses SVD approach (one can choose the kaiser criteria to choose the number of dimensions). Why we do 2)? a) TF-IDF is very sparse. Step 3 (tSne) which is computationally expensive. b) This LSA can be used to create a semantic search engine You can bypass 2) when your TF-IDF size is very small but i don't think given your situation that would be the case and also, you don't have other needs like having semantic search on these documents. 3) Use tSne (t-stochastic nearest embedding) to represent the documents in 3 dimensions. Prepare a spherical plot from the euclidean cordinates. 4) Apply K-means iteratively to find the optimal number of clusters. Once decided. Prepare word clouds for each categories. Have your themes.
I am trying to do textual analysis on a bunch (about 140 ) of textual documents. Each document, after preprocessing and removing unnecessary words and stopwords, has about 7000 sentences (as determined by nlkt's sentence tokenizer) and each sentence has about 17 words on average. My job is to find hidden themes in those documents. I have thought about doing topic modeling. However, I cannot decide if the data I have is enough to obtain meaningful results via LDA or is there anything else that I can do. Also, how do I divide the texts into different documents? Is 140 documents (each with roughly 7000 x 17 words) enough ? or should I consider each sentence as a document. But then each document will have only 17 words on average; much like tweets. Any suggestions would be helpful. Thanks in advance.
0
1
66
0
51,581,196
0
0
0
0
1
false
2
2017-12-15T19:25:00.000
7
2
0
reducing word2vec dimension from Google News Vector Dataset
47,838,719
1
python-3.x,gensim
tl;dr Use a dimensionality reduction technique like PCA or t-SNE. This is not a trivial operation that you are attempting. In order to understand why, you must understand what these word vectors are. Word embeddings are vectors that attempt to encode information about what a word means, how it can be used, and more. What makes them interesting is that they manage to store all of this information as a collection of floating point numbers, which is nice for interacting with models that process words. Rather than pass a word to a model by itself, without any indication of what it means, how to use it, etc, we can pass the model a word vector with the intention of providing extra information about how natural language works. As I hope I have made clear, word embeddings are pretty neat. Constructing them is an area of active research, though there are a couple of ways to do it that produce interesting results. It's not incredibly important to this question to understand all of the different ways, though I suggest you check them out. Instead, what you really need to know is that each of the values in the 300 dimensional vector associated with a word were "optimized" in some sense to capture a different aspect of the meaning and use of that word. Put another way, each of the 300 values corresponds to some abstract feature of the word. Removing any combination of these values at random will yield a vector that may be lacking significant information about the word, and may no longer serve as a good representation of that word. So, picking the top 100 values of the vector is no good. We need a more principled way to reduce the dimensionality. What you really want is to sample a subset of these values such that as much information as possible about the word is retained in the resulting vector. This is where a dimensionality reduction technique like Principle Component Analysis (PCA) or t-distributed Stochastic Neighbor Embeddings (t-SNE) come into play. I won't describe in detail how these methods work, but essentially they aim to capture the essence of a collection of information while reducing the size of the vector describing said information. As an example, PCA does this by constructing a new vector from the old one, where the entries in the new vector correspond to combinations of the main "components" of the old vector, i.e those components which account for most of the variety in the old data. To summarize, you should run a dimensionality reduction algorithm like PCA or t-SNE on your word vectors. There are a number of python libraries that implement both (e.g scipy has a PCA algorithm). Be warned, however, that the dimensionality of these word vectors is already relatively low. To see how this is true, consider the task of naively representing a word via its one-hot encoding (a one at one spot and zeros everywhere else). If your vocabulary size is as big as the google word2vec model, then each word is suddenly associated with a vector containing hundreds of thousands of entries! As you can see, the dimensionality has already been reduced significantly to 300, and any reduction that makes the vectors significantly smaller is likely to lose a good deal of information.
I loaded google's news vector -300 dataset. Each word is represented with a 300 point vector. I want to use this in my neural network for classification. But 300 for one word seems to be too big. How can i reduce the vector from 300 to say 100 without compromising on the quality.
0
1
2,005
0
47,839,249
0
0
0
0
1
false
0
2017-12-15T19:30:00.000
0
2
0
Plotting a 3d surface in Python from known values
47,838,811
0
python,arrays,numpy,matplotlib,multidimensional-array
use x and y as coordinates and put a dot sized for the energy z. a table would work as well, since you haven't stated that x and y geometries have any numeric purpose other than as lablels.
I have a set of about 2000 files that look like: 10_20.txt, 10_21.txt, 10_21.txt, ... ,10_50.txt, ... , 11.20.txt, ... , 11.50.txt , ... , 20_50.txt The first value in the file name, we'll call x, goes from 10-20 in steps of 1, and the second value in the file name, we'll call y, and goes from 20-50 in steps of 1. Within these files, there is a load of values and another value I want to extract, which we'll call z. I have written a program to cycle through the files and extract z from each file and add it to a list. My question now is, if I have 2 numpy arrays that look like: x = np.arange(10,20,1) y = np.arange(20,50,1) and a z list that has ~2000 floats in it, what is the best way to plot how z depends on x and y? Is there standard way to do this? I had been thinking it would be best to extract x, y and z from a file, and add them to a multidimensional array. If this is the case could anyone point me in the right direction of how to extract the x and y values out of the file name.
0
1
470
0
48,814,986
0
0
0
0
2
false
3
2017-12-17T18:23:00.000
0
2
0
scipy ImportError: dlopen no suitable image found in Python 3
47,858,150
0
scipy,python-3.6
Looks like I am the only one on earth to have this issue. Fortunately, I got it to work with endless attempts. In case someone in the future gets the same error, you can try this:python -m pip install scipy. I have no idea why pip install scipy doesn't work.
I have python 3.6, Mac OS X El Capitan. I installed scipy by pip install scipy. But when I import scipy, I get the following error: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/init.py in () 116 del _NumpyVersion 117 --> 118 from scipy._lib._ccallback import LowLevelCallable 119 120 from scipy._lib._testutils import PytestTester /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback.py in () ----> 1 from . import _ccallback_c 2 3 import ctypes 4 5 PyCFuncPtr = ctypes.CFUNCTYPE(ctypes.c_void_p).bases[0] ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so: mach-o, but wrong architecture I don't get this error in Python2.
0
1
5,874
0
54,552,819
0
0
0
0
2
false
3
2017-12-17T18:23:00.000
0
2
0
scipy ImportError: dlopen no suitable image found in Python 3
47,858,150
0
scipy,python-3.6
What I did find on MacOS 10.14.2 is that I had installed Scipy 1.1. After executing python -m pip install scipy I got Scipy 1.2 and get rid of "ImportError: dlopen".
I have python 3.6, Mac OS X El Capitan. I installed scipy by pip install scipy. But when I import scipy, I get the following error: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/init.py in () 116 del _NumpyVersion 117 --> 118 from scipy._lib._ccallback import LowLevelCallable 119 120 from scipy._lib._testutils import PytestTester /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback.py in () ----> 1 from . import _ccallback_c 2 3 import ctypes 4 5 PyCFuncPtr = ctypes.CFUNCTYPE(ctypes.c_void_p).bases[0] ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so: mach-o, but wrong architecture I don't get this error in Python2.
0
1
5,874
0
49,210,718
0
1
0
0
3
false
5
2017-12-18T00:34:00.000
2
3
0
Error loading tensorflow - Could not find "cudart64_80.dll"
47,860,803
0.132549
python,tensorflow,tensorflow-gpu
I had a similar issue, but with the version 9.1 which I had on my machine. The one which was missing 'cudart64_90.dll', whereas there was 'cudart64_91.dll'. So I did a 'downgrade' from CUDA 9.1 to 9.0 and it solved my problem. Hope it helps.
I am trying to import tensorflow (with GPU) and keep getting the following error: ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable Setup: NVIDIA GTX 1080 CUDA Development Tool v8.0 cuDNN 6.0 tensorflow-gpu 1.4 Environment variables: CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH_V8.0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 I have also added the following to the %PATH% variable: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64 What am I missing? Why it can't find cudart64_80.dll despite its location is explicitly specified in %PATH%? Any help would be much appreciated.
0
1
12,211
0
47,864,449
0
1
0
0
3
true
5
2017-12-18T00:34:00.000
1
3
0
Error loading tensorflow - Could not find "cudart64_80.dll"
47,860,803
1.2
python,tensorflow,tensorflow-gpu
In certain cases you may need to restart the computer to propagate all the changes. If you are using intellij or pycharm, make sure to restart that as it may not take the correct path environment variables otherwise.
I am trying to import tensorflow (with GPU) and keep getting the following error: ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable Setup: NVIDIA GTX 1080 CUDA Development Tool v8.0 cuDNN 6.0 tensorflow-gpu 1.4 Environment variables: CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH_V8.0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 I have also added the following to the %PATH% variable: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64 What am I missing? Why it can't find cudart64_80.dll despite its location is explicitly specified in %PATH%? Any help would be much appreciated.
0
1
12,211
0
57,690,869
0
1
0
0
3
false
5
2017-12-18T00:34:00.000
0
3
0
Error loading tensorflow - Could not find "cudart64_80.dll"
47,860,803
0
python,tensorflow,tensorflow-gpu
I just changed cudart64_90 to cudart64_80. It worked
I am trying to import tensorflow (with GPU) and keep getting the following error: ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable Setup: NVIDIA GTX 1080 CUDA Development Tool v8.0 cuDNN 6.0 tensorflow-gpu 1.4 Environment variables: CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH_V8.0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 I have also added the following to the %PATH% variable: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64 What am I missing? Why it can't find cudart64_80.dll despite its location is explicitly specified in %PATH%? Any help would be much appreciated.
0
1
12,211
0
55,399,149
0
0
0
1
2
false
1
2017-12-18T23:46:00.000
-1
2
0
Pandas .to_sql is not inserting any records for a dataframe I want to send to sql. Are there any generic reasons why this might be the case?
47,878,076
-0.099668
python,sql,python-3.x,postgresql,pandas
I was also facing same issue because dot was added in header. remove dot then it will work.
Pandas .to_sql is not inserting any records for a dataframe I want to send to sql. Are there any generic reasons why this might be the case? I am not getting any error messages. The column names appear fine, but the table is entirely empty. When I try to send over a single column (i.e. data.ix[2]), it actually works. However, if I try to send over more than one column (data.ix[1:3]), I again get a completely blank table in sql. I have been using this code for other dataframes and have never encountered this problem. It still runs for other dataframes in my set.
0
1
2,183
0
47,896,038
0
0
0
1
2
false
1
2017-12-18T23:46:00.000
0
2
0
Pandas .to_sql is not inserting any records for a dataframe I want to send to sql. Are there any generic reasons why this might be the case?
47,878,076
0
python,sql,python-3.x,postgresql,pandas
I fixed this problem - it was becomes some of the column headers had '%' in it. I accidentally discovered this reason for the empty tables when I tried to use io and copy_from a temporary csv, instead of to_sql. I got a transaction error based on a % placeholder error. Again, this is specific to passing to PSQL; it went through to SQL Server without a hitch.
Pandas .to_sql is not inserting any records for a dataframe I want to send to sql. Are there any generic reasons why this might be the case? I am not getting any error messages. The column names appear fine, but the table is entirely empty. When I try to send over a single column (i.e. data.ix[2]), it actually works. However, if I try to send over more than one column (data.ix[1:3]), I again get a completely blank table in sql. I have been using this code for other dataframes and have never encountered this problem. It still runs for other dataframes in my set.
0
1
2,183
0
58,295,830
0
1
0
0
1
false
2
2017-12-19T17:13:00.000
2
3
0
import tensorflow in Anaconda prompt
47,892,038
0.132549
python
I was looking for a similar issue (unable to import tensorflow in jupyter) and found that maybe most answers are outdated because now conda installs tf in its own environment. The most useful thing I found is: https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/ which explains in very few steps how to install tf or tf-gpu in its own environment. Then my problem was that the jupyter notebook is in its own base environment, not in the tf-gpu environment. How to work with that from a jupyter notebook based on the base environment? The solution comes from the very helpful answer from Nihal Sangeeth to this question https://stackoverflow.com/questions/53004311/how-to-add-conda-environment-to-jupyter-lab conda activate tf-gpu (tf-gpu)$ conda install ipykernel (tf-gpu)$ ipython kernel install --user --name=<any_name_you_like_for_kernel> (tf-gpu)$ conda deactivate Close and reopen your jupyter notebook. Then in your jupyter notebook you will find the option, under "kernel" of "change kernel". Change kernel to your newly created kernel and you will be able to import tensorflow as tf and go on from there. Hope it helps somebody
ModuleNotFoundError Traceback (most recent call last) in () 11 import numpy as np 12 ---> 13 import tensorflow as tf 14 15 ModuleNotFoundError: No module named 'tensorflow'
0
1
9,109
0
47,898,790
0
0
0
0
1
true
0
2017-12-20T03:56:00.000
1
1
0
Variable length array reshape for input to CNN
47,898,566
1.2
python,tensorflow,keras
I don't think 'None' can be accepted in any reshape function. Reshape functions usually require numeric size. But you can reshape 'None' part to 1 to fit the model you are using. For reshaping, considering x is the variable that needs to be reshaped, Using Numpy, x = np.reshape(x, (1000, 1, 1, 1)) Using Tensorflow, x = tf.reshape(x, (1000, 1, 1, 1))
I want to ask about how I reshape an array with a different number of elements, For example, the size of the array is (1000,). I want to reshape it to be (1000, None,None,1) to be the input to CNN, I'm using keras.
0
1
373
0
50,867,759
0
0
0
0
1
false
0
2017-12-20T11:36:00.000
0
1
0
text classification using logistic regression
47,905,139
0
python,text-classification
If you have 3 classes and labelled data and have trained the model, then you have "told the classifier" everything you can (ie trained). If you're saying you want to tell the classifier about the 2/6 test cases that failed, you then no its not possible with Logistic Regression (maybe some other feedback model?). What you need is to train the model more, or add more test cases. You could add those 2 failed cases to training and try different test data. You may have an underfit model you can try to tune, but with the experiments I've done with text similar to yours it can be difficult to obtain really high accuracy with limited data and just tf-idf since the "model" is just word frequencies.
I am planning to classify emails. I am using tfidf vectorizer and logistic regression algorithm to do this. I took very small training and testing sets. My training set consists of 150 emails( 3 classes, 50 emails/class) and testing set consists of 6 emails. Now my classifier is predicting 4 out of 6 correctly. Now my doubt is, can I tell the classifier that this document belongs to class X not class Y? If yes, What is this process called? Thank you.
0
1
422
0
47,918,220
0
0
0
0
2
false
2
2017-12-20T11:59:00.000
2
2
0
How to use Gensim Doc2vec infer_vector() for large DataFrame?
47,905,576
0.197375
python,gensim,doc2vec
Doc2Vec infer_vector() only takes individual text examples, as lists-of-word-tokens. So you can't pass in a batch of examples. (And, you shouldn't be passing in non-tokenized strings – but lists-of-tokens, preprocessed in the same manner as your training data was preprocessed.) But, you might be able to use a function that multiply-applies infer_vector() for you, as the @COLDSPEED comment suggests. Still, the column should have lists-of-tokens, rather than strings-of-characters, if you want meaningful results. Also, most users find infer_vector() works much better using non-default values for its steps parameter (much larger than its default of 5), and perhaps smaller values for its starting alpha parameter (such as more like the training default of 0.025 than the inference default of 0.1).
I have created document vectors for a large corpus using Gensim's doc2vec. sentences=gensim.models.doc2vec.TaggedLineDocument('file.csv') model = gensim.models.doc2vec.Doc2Vec(sentences,size = 10, window = 800, min_count = 1, workers=40, iter=10, dm=0) Now I am using Gensim's infer_vector() using those document vectors to create document vectors for another sample corpus Eg: model.infer_vector('This is a string') Is there a way to pass the entire DataFrame through infer_vector and get the output vectors for each line in the DataFrame?
0
1
1,915
0
47,925,223
0
0
0
0
2
false
2
2017-12-20T11:59:00.000
0
2
0
How to use Gensim Doc2vec infer_vector() for large DataFrame?
47,905,576
0
python,gensim,doc2vec
@gojomo: Thanks for the answer, but I tried inferring using both tokenized rows as well as raw strings, and got the same document vector. Is there a way to know if the document vector which are getting created are meaningful or not?
I have created document vectors for a large corpus using Gensim's doc2vec. sentences=gensim.models.doc2vec.TaggedLineDocument('file.csv') model = gensim.models.doc2vec.Doc2Vec(sentences,size = 10, window = 800, min_count = 1, workers=40, iter=10, dm=0) Now I am using Gensim's infer_vector() using those document vectors to create document vectors for another sample corpus Eg: model.infer_vector('This is a string') Is there a way to pass the entire DataFrame through infer_vector and get the output vectors for each line in the DataFrame?
0
1
1,915
0
47,928,522
0
0
0
0
1
false
3
2017-12-21T15:48:00.000
2
1
0
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory (Shared Linux)
47,928,371
0.379949
python,ubuntu,tensorflow,cublas
A likely explanation is that your path is not set up correctly. Try echo $LD_LIBRARY_PATH and let us know what you get. Another explanation is that it is not in that directory. Yes, libcublas.so should normally be in /usr/local/cuda-8.0/lib64 but double check if it is there or another directory by using find.
I am new to tensorflow and I am working on shared linux (Ubuntu 16.04), it means I don't have root access. Cuda 8.0 and Cudnn 8 are already installed by admin as root. I have installed python 3.5 using anaconda and then installed tensorflow using pip. I have added the cuda-8.0/bin and cuda-8.0/lib64 to PATH and LD_PATH_LIBRARY using following exports. export PATH="$PATH:/usr/local/cuda-8.0/bin" export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64" But when I try to run the program it gives the following error. ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory However these files exist in LD_LIBRARY_PATH, and nvcc -V is also working. Is it even possible to refer to the system installed Cuda and CuDnn ? If yes, can you help to clear the above error. Thanks in advance.
0
1
1,016
0
47,934,883
0
0
0
0
1
false
1
2017-12-22T00:10:00.000
0
2
0
Create a dataframe by discarding intersections of two dataframes (Pandas)
47,934,376
0
python,pandas,dataframe
If you have both dataframes of same length you can also use: print df1.loc[df1['ID'] != df2['ID']] assign it to a third dataframe.
Does anyone know of an efficient way to create a new dataframe based off of two dataframes in Python/Pandas? What I am trying to do is check if a value from df1 is in df2, then do not add the row to df3. I am working with student IDS, and if a student ID from df1 is in df2, I do not want to include it in the new dataframe, df3. So does anybody know an efficient way to do this? I have googled and looked on SO, but found nothing that works so far.
0
1
226
0
47,942,101
0
1
0
0
1
false
0
2017-12-22T12:06:00.000
0
1
0
Able to fetch text with their locations from an image...How can I form sentence?
47,941,250
0
javascript,python,image-processing,ocr,image-conversion
I don't if I am understanding your problem correctly, but I'm assuming each dictionary in your json is giving you the coordinates for a word. My approach would be to first find the difference in pixels for the space between any 2 words, and you use this value to detect the sequence of words. For example: img1 = {'coordinates': 'information'} img2 = {'coordinates': 'information'} space_value = 10 # for example if img1['Height'] == img2['Height'] and (img1['Left'] + img1['Width'] + space_value) == img2['Left']: next_word = True
I am using online library and able to fetch words from an image with their locations. Now I want to form sentences exactly like which are in image. Any idea how can I do that? Earlier i used the distance between two words and if there are pretty close then it means it is a part of a sentence but this approach is not working fine Please help This is the json I am receiving I have... "WordText": "Word 1", "Left": 106, "Top": 91, "Height": 9, "Width": 11 }, { "WordText": "Word 2", "Left": 121, "Top": 90, "Height": 13, "Width": 51 } . . . More Words
0
1
41
0
51,340,436
0
0
0
0
1
false
7
2017-12-22T19:34:00.000
3
2
0
Python fbprophet - export values from plot_components() for yearly
47,946,518
0.291313
python-3.x,time-series,facebook-prophet
There is a simple solution in the current version of the library. You can use from the predicted model fc. What you want for the value of yearly can be found with fc['yearly'] without using the functions in the above solution. Moreover, if you want all the other components like trend, you can use fc['trend'].
Any ideas on how to export the yearly seasonal trend using fbprophet library? The plot_components() function plots the trend, yearly, and weekly. I want to obtain the values for yearly only.
0
1
3,166
0
47,976,344
0
0
0
0
1
false
0
2017-12-22T21:43:00.000
0
1
0
How to display OpenCV camera stream in the same window as another file?
47,947,718
0
python,opencv,imshow
I think the GUI you're talking about is Tkinter, but opencv's cv.imshow is just playing frame.I don't think it's necessary to use GUI to show frame.Because cv2.imshow is good at handling.
I have been trying to use OpenCV to display my camera stream in the same window as another (GUI) window. However, the imshow() method opens its own window. Is there another way to do this so that it displays in the same window as my GUI?
0
1
223
0
47,958,997
0
0
0
0
1
true
4
2017-12-24T07:01:00.000
-1
1
0
Save OneHot Encoder object python
47,958,697
1.2
python,scikit-learn,one-hot-encoding
simple use of pickel for OHE will do for me.
Is there anyway of saving OneHotencoder object in python? . Reason is being I used that object in preprocessing of training data and test data and we are building a API containing the same trained model and that will be injected by real data from the website when user created. So first that data needs to be preprocessed and then model can predict o/p for the same. Thanks
0
1
1,953
0
48,297,553
0
0
0
0
1
false
0
2017-12-24T23:52:00.000
0
1
0
Tensorflow trained model works on cloud machine but gives an error when used in my local pc
47,964,765
0
python,tensorflow,machine-learning,deep-learning
Are the cloud and local machines running the same Python/Tensorflow versions? Sometimes checkpoints produced by a specific Tensorflow version are not backward compatible due to internal variables renaming.
I've tried to create a custom object detector in the paperspace cloud desktop, then I tried it on Jupyter Notebook and it works. Now, I've uploaded the whole models-master folder and downloaded it on my local machine. I ran it using Jupyter Notebook and it now gives an InvalidArgumentError. I've tried re-exporting the inference graph on my local machine using the same ckpt that was trained on cloud but it is still not working. InvalidArgumentError Traceback (most recent call last) /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args) 1322 try: -> 1323 return fn(*args) 1324 except errors.OpError as e: /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata) 1301 feed_dict, fetch_list, target_list, -> 1302 status, run_metadata) 1303 /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py in exit(self, type_arg, value_arg, traceback_arg) 472 compat.as_text(c_api.TF_Message(self.status.status)), --> 473 c_api.TF_GetCode(self.status.status)) 474 # Delete the underlying status object from memory otherwise it stays alive InvalidArgumentError: NodeDef mentions attr 'T' not in Op index:int64>; NodeDef: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.). [[Node: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0"]] During handling of the above exception, another exception occurred: InvalidArgumentError Traceback (most recent call last) in () 20 (boxes, scores, classes, num) = sess.run( 21 [detection_boxes, detection_scores, detection_classes, num_detections], ---> 22 feed_dict={image_tensor: image_np_expanded}) 23 # Visualization of the results of a detection. 24 vis_util.visualize_boxes_and_labels_on_image_array( /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 887 try: 888 result = self._run(None, fetches, feed_dict, options_ptr, --> 889 run_metadata_ptr) 890 if run_metadata: 891 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1118 if final_fetches or final_targets or (handle and feed_dict_tensor): 1119 results = self._do_run(handle, final_targets, final_fetches, -> 1120 feed_dict_tensor, options, run_metadata) 1121 else: 1122 results = [] /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1315 if handle is None: 1316 return self._do_call(_run_fn, self._session, feeds, fetches, targets, -> 1317 options, run_metadata) 1318 else: 1319 return self._do_call(_prun_fn, self._session, handle, feeds, fetches) /usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args) 1334 except KeyError: 1335 pass -> 1336 raise type(e)(node_def, op, message) 1337 1338 def _extend_graph(self): InvalidArgumentError: NodeDef mentions attr 'T' not in Op index:int64>; NodeDef: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.). [[Node: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0"]] Caused by op 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where', defined at: File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel_launcher.py", line 16, in app.launch_new_instance() File "/home/ryan/.local/lib/python3.5/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 477, in start ioloop.IOLoop.instance().start() File "/home/ryan/.local/lib/python3.5/site-packages/zmq/eventloop/ioloop.py", line 177, in start super(ZMQIOLoop, self).start() File "/home/ryan/.local/lib/python3.5/site-packages/tornado/ioloop.py", line 888, in start handler_func(fd_obj, events) File "/home/ryan/.local/lib/python3.5/site-packages/tornado/stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "/home/ryan/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events self._handle_recv() File "/home/ryan/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv self._run_callback(callback, msg) File "/home/ryan/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback callback(*args, **kwargs) File "/home/ryan/.local/lib/python3.5/site-packages/tornado/stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher return self.dispatch_shell(stream, msg) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell handler(stream, idents, msg) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 399, in execute_request user_expressions, allow_stdin) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/ipkernel.py", line 196, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "/home/ryan/.local/lib/python3.5/site-packages/ipykernel/zmqshell.py", line 533, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "/home/ryan/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2728, in run_cell interactivity=interactivity, compiler=compiler, result=result) File "/home/ryan/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2850, in run_ast_nodes if self.run_code(code, result): File "/home/ryan/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 7, in tf.import_graph_def(od_graph_def, name='') File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 313, in import_graph_def op_def=op_def) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op op_def=op_def) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1470, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access InvalidArgumentError (see above for traceback): NodeDef mentions attr 'T' not in Op index:int64>; NodeDef: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.). [[Node: Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/FilterGreaterThan/Where = WhereT=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]
0
1
665
0
47,965,130
0
0
0
0
1
false
1
2017-12-25T01:08:00.000
1
2
0
OpenCV Error: Assertion failed (_img.rows * _img.cols == vecSize)
47,965,021
0.099668
python-3.x,opencv,cascade,assertion
I solved it haha. Even though I specified in the command the width and height to be 20x20, it changed it to 20x24. So the opencv_traincascade command was throwing an error. Once I changed the width and height arguments in the opencv_traincascade command it worked.
I keep getting this error OpenCV Error: Assertion failed (_img.rows * _img.cols == vecSize) in get, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp, line 157 terminate called after throwing an instance of 'cv::Exception' what(): /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp:157: error: (-215) _img.rows * _img.cols == vecSize in function get Aborted (core dumped) when running opencv_traincascade. I run with these arguments: opencv_traincascade -data data -vec positives.vec -bg bg.txt -numPos 1600 -numNeg 800 -numStages 10 -w 20 -h 20. My project build is as follows: workspace |__bg.txt |__data/ # where I plan to put cascade |__info/ |__ # all samples |__info.lst |__jersey5050.jpg |__neg/ |__ # neg images |__opencv/ |__positives.vec before I ran opencv_createsamples -img jersey5050.jpg -bg bg.txt -info info/info.lst -maxxangle 0.5 - maxyangle 0.5 -maxzangle 0.5 -num 1800 Not quite sure why I'm getting this error. The images are all converted to greyscale as well. The neg's are sized at 100x100 and jersey5050.jpg is sized at 50x50. I saw someone had a the same error on the OpenCV forums and someone suggested deleting the backup .xml files that are created b OpenCV in case the training is "interrupted". I deleted those and nothing. Please help! I'm using python 3 on mac. I'm also running these commands on an ubuntu server from digitalocean with 2GB of ram but I don't think that's part of the problem. EDIT Forgot to mention, after the opencv_createsamples command, i then ran opencv_createsamples -info info/info.lst -num 1800 -w 20 -h20 -vec positives.vec
0
1
2,068
0
47,973,889
0
1
0
0
2
false
2
2017-12-26T01:43:00.000
0
3
0
Cannot import FactorAnalyzer from module factor-analyzer-0.2.2
47,973,216
0
python,python-3.x
Can you try to run the import command on your Python Shell and let us know if you are able to import it successfully?
I installed the module factor-analyzer-0.2.2 but cannot import the function. My code is from factor_analyzer import FactorAnalyzer. I'm getting an error ModuleNotFoundError: No module named 'factor_analyzer'. I'm using Python 3.6 and Jupyter notebook. Do you know why this does not work? Thank you!!
0
1
5,421
0
58,283,301
0
1
0
0
2
false
2
2017-12-26T01:43:00.000
1
3
0
Cannot import FactorAnalyzer from module factor-analyzer-0.2.2
47,973,216
0.066568
python,python-3.x
Use the anaconda prompt to run the pip install factor-analyzer rather than termainal or powershell. I had the same problem and doing that solved it for me.
I installed the module factor-analyzer-0.2.2 but cannot import the function. My code is from factor_analyzer import FactorAnalyzer. I'm getting an error ModuleNotFoundError: No module named 'factor_analyzer'. I'm using Python 3.6 and Jupyter notebook. Do you know why this does not work? Thank you!!
0
1
5,421
0
47,985,532
0
0
0
0
1
false
1
2017-12-26T12:27:00.000
0
2
0
How to read data in HDF5 format file partially when the data is too large to read fully
47,978,664
0
python,hdf5,h5py
You can slice h5py datasets like numpy arrays, so you could work on a number of subsets instead of the whole dataset (e.g. 4 100000*10000 subsets).
I am engaged in analysing HDF5 format data for scientific research purposes. I'm using Python's h5py library. Now, the HDF file I want to read is so large. Its file size is about 20GB and the main part of its data is 400000*10000 float matrix. I tried to read the data once, but my development environment Spyder was terminated by compulsion because of the shortage of the memory. Then is there any method to read it partially and avoid this problem?
0
1
1,280
0
47,990,202
0
0
0
0
1
true
0
2017-12-27T08:43:00.000
2
2
0
How does Keras read input data?
47,988,983
1.2
python,machine-learning,neural-network,keras,keras-layer
input_dim=3 means that your data have 3 features which will be used to determine final result eg. if you want to determine what animal data refer to you could put width, height and color as data. 100 examples of different animals widths, heights and colors combinations allow neural network to adjust its parameters (learn) what width, height and color refers to what kind of animal. Keras starts with random weights for neurons and goes one by one 100 times using provided samples to adjust network weights. Keras actually uses batches which means 100 samples are divided into smaller groups for better learning rate and general performance (less data to store in memory at once). 10 neurons are 10 'places' where network is able to store multiplications results between neuron weights and input data. You could imagine neuron as a bulb which lights a bit brighter or darker depending whether data shows some useful data feature eg. if animal is above 3 meters tall. Each neuron has its own set of weights which are changed just a bit when network examines next sample from your data. At the end you should have 10 neurons (bulbs) which react in more or less intense way depending on presence of different features in your data eg. if animal is very tall. The more neurons you have the more possible features you can track eg. if animal is tall, hairy, orange, spotted etc. But the more neurons you have there is also the higher risk that your network will be too exact and will learn features which are unique for your training example (it's called overfitting) but do not help you to recognize animal samples which were not included in your training data (it's called ability to generalize and is most important point of actually training neural network). Selecting number of neurons is then a bit of practical exercise where you search for one which works for your need. I hope it clarifies your doubts. If you would like to get deeper in this field there are a lot of good resources online explaining neural networks training process in details including features, neurons and learning.
I am using Keras for a project and I don't understand how Keras uses data input, that is to say how Keras reads our input data when creating the first layer. For example: model = Sequential() model.add(Dense(10, activation='sigmoid', input_dim=3,name='layer1')) In this model, what does it mean to have 10 neurons and an input with 3 dimensions? If the input data has 100 examples (number of lines in the matrix data), how does Keras use them? Thank you.
0
1
1,223
0
49,556,042
0
0
0
0
1
false
0
2017-12-28T07:39:00.000
1
1
0
Neural network with a single out with tensorflow
48,003,535
0.197375
python,tensorflow,machine-learning,computer-vision,deep-learning
Just use the sigmoid layer as the final layer. There's no need for any cross entropy when you have a single output, so just let the loss function work on the sigmoid output which is limited to the output range you want.
I want to make a neural network that has one single output neuron on the last layer that tells me the probability of there being a car on an image (the probability going from 0 - 1). I'm used to making neural networks for classification problems, with multiple output neurons, using the tf.nn.softmax_cross_entropy_with_logits() and tf.nn.softmax() methods. But these methods don't work when there is only one column for each sample in the labels matrix since the softmax() method will always return 1. I tried replacing tf.nn.softmax() with tf.nn.sigmoid() and tf.nn.softmax_cross_entropy_with_logits() with tf.nn.sigmoid_cross_entropy_with_logits(), but that gave me some weird results, I might have done something wrong in the implementation. How should I define the loss and the predictions on a neural network with only one output neuron?
0
1
430
0
48,015,138
0
0
0
0
1
false
0
2017-12-28T22:20:00.000
0
1
0
Neural Network: Extra features used for training but not for predicting new data
48,015,101
0
python,neural-network,keras,recurrent-neural-network
The number of goals would be an output, not an input. For example, you could build a model to predict how many goals each team would score... If you used goals scored as an input, the model train to be incredibly simple and useless- just comparing the goals, ignoring all other inputs.
I want to do a neural network to predict who is going to win a soccer game. I have several features (like the team, the physical shape of the team, etc.) and an output, telling which team won (or if there was a die). In my training, I want to add features like the number of goals these teams scored. The problem is that I won't be able to include these features when predicting the final result of a future game. Is there a way to do it ? I'm using Keras in Python as a library to easily build neural networks.
0
1
26
0
50,180,152
0
0
0
1
2
false
4
2017-12-29T17:21:00.000
0
5
0
AWS Glue Truncate Redshift Table
48,026,111
0
python,amazon-web-services,pyspark,amazon-redshift,aws-glue
You need to modify the auto generated code provided by Glue. Connect to redshift using spark jdbc connection and execute the purge query. To spin up Glue containers in redshift VPC; specify the connection in glue job, to gain access for redshift cluster. Hope this helps.
I have created a Glue job that copies data from S3 (csv file) to Redshift. It works and populates the desired table. However, I need to purge the table during this process as I am left with duplicate records after the process completes. I'm looking for a way to add this purge to the Glue process. Any advice would be appreciated. Thanks.
0
1
4,214
0
65,486,258
0
0
0
1
2
false
4
2017-12-29T17:21:00.000
2
5
0
AWS Glue Truncate Redshift Table
48,026,111
0.07983
python,amazon-web-services,pyspark,amazon-redshift,aws-glue
The link @frobinrobin provided is out of date, and I tried many times that the preactions statements will be skiped even you provide a wrong syntax, and came out with duplicated rows(insert action did executed!) Try this: just replace the syntax from glueContext.write_dynamic_frame.from_jdbc_conf() in the link above to glueContext.write_dynamic_frame_from_jdbc_conf() will works! At least this help me out in my case(AWS Glue job just insert data into Redshift without executing Truncate table actions)
I have created a Glue job that copies data from S3 (csv file) to Redshift. It works and populates the desired table. However, I need to purge the table during this process as I am left with duplicate records after the process completes. I'm looking for a way to add this purge to the Glue process. Any advice would be appreciated. Thanks.
0
1
4,214
0
48,042,507
0
0
0
0
1
false
0
2017-12-30T18:28:00.000
0
3
0
Acceptance-rate in PyMC3 (Metropolis-Hastings)
48,036,741
0
python,pymc3
Let step = pymc3.Metropolis() be our sampler, we can get the final acceptance-rate through "step.accepted" Just for beginners (pymc3) like myself, after each variable/obj. put a "." and hit the tab key; you will see some interesting suggestions ;)
Does anyone know how I can see the final acceptance-rate in PyMC3 (Metropolis-Hastings) ? Or in general, how can I see all the information that pymc3.sample() returns ? Thanks
0
1
551
0
48,048,843
0
0
0
0
1
false
0
2018-01-01T07:06:00.000
2
1
0
Are Tensorflow Variables essential?
48,047,793
0.379949
python,tensorflow
The main benefit of using tf.Variables is you don't have to explicitly state what to optimize when you train a neural network. From the perspective of Machine Learning, Variables are network parameters (or weights) which have some initial value before training but get optimized during training (The gradients of the loss are calculated with respect to the Variables and using an Optimization Algorithm, their Variables are updated. (the famous equation w = w - alpha*dL_dw for SGD Algorithm). In contrast, tf.constant is used to store those network parameters for which gradients of the loss are not intended. During training, the gradients of the loss with respect to constants are not calculated and hence their values are not updated. In order to feed the network with inputs, we use tf.placeholder. Are they essential? Yes. A deep neural network has millions of parameters across dozens of Variables and though one can define tensors with some initial value (based on some heuristics, like Glorot initialization) calculate the gradient of the loss with respect to each of them (maybe using a for loop) update their values based on some optimization algorithm (e.g., SGD) taking extra care not to leave behind any of them, a wise person will just use Variables and let the magic happen. After all, more and messy code means more chances of error.
I pretty much understand the concept of Variable in Tensorflow (I think) but I still haven't found them very useful. The main reason I read it is interesting to use them it's to later restore them, which might be handy in some cases, but you could achieve similar results using numpy.save for saving matrices and values, or even writing them out in a log file. Variables are used to save Tensors but you can use a Python variable to save them, avoiding the Tensorflow's Variable extra wrapper. Variables become nice when used using get_variable function since the code will be much cleaner than using dictionary to store weights, however, in terms of functionality, I don't get why are they important. My conclusion about TF Variables is that they help us to write nicer code but they are not essential. Any thoughts about them?
0
1
52
0
48,071,714
0
0
0
1
1
false
0
2018-01-02T18:09:00.000
0
1
0
Sort by two columns, why not do grouping first?
48,065,753
0
python,sql,pandas,sorting,group-by
Here is the answer to it- Grouping is done when you want to pull out the conclusion based on the entire group , like total of sales done,for each of the groups(in this case John and Amy) . It is used mostly with an aggregate function or sometimes to select distinct records only. What you wrote above is sorting the data in the order of name and sales , there is no grouping involved at all. Since the operation is sorting , its obvious that the command written for it would be sorting .
I have two columns, one is a string field customer containing customer names and the other is a numeric field sales representing sales. What I want to do is to group data by customer and then sort sales within group. In SQL or Pandas, this is normally achieved by something like order by customer, sales on the table. But I am just curious about this implementation. Instead first sorting on customer and then sorting on sales, why not first group customer and sort sales. I don't really care about the order of the different customers since I only care about records of same customers being grouped together. Grouping is essentially mapping and should run faster than sorting. Why isn't there such implementation in SQL? Am I missing something? Example data name,sales john,1 Amy,1 john,2 Amy,3 Amy,4 and I want it to group by name and then sort by sales: name,sales john,1 john,2 Amy,1 Amy,3 Amy,4 In SQL you probably would do select * from table order by name,sales This would definitely do the job. But my confusion is since I don't care about the order of name, I should be able to do some kind of grouping (which should be cheaper than sorting) first and do sorting only on the numeric field. Am I able to do this? Why do a lot of examples from google simply uses sorting on the two fields? Thanks!
0
1
119
0
48,076,093
0
1
0
0
2
false
0
2018-01-03T10:58:00.000
1
2
0
ImportError: No module named cv2 error upon running .py file in terminal
48,076,009
0.099668
python,macos,opencv
Package name is wrong pip install opencv-python Should work.
I am having trouble running a python script file that contains import opencv command. Upon running the file, it gives the following error: ImportError: No module named cv2 I then ran pip install python-opencv but it gave Could not find a version that satisfies the requirement python-opencv (from versions: ) No matching distribution found for python-opencv error. Does anyone know what the issue might be? I was able to run this python file at first but I haven't been able to run after that.
0
1
542
0
48,076,121
0
1
0
0
2
false
0
2018-01-03T10:58:00.000
0
2
0
ImportError: No module named cv2 error upon running .py file in terminal
48,076,009
0
python,macos,opencv
I also had this issue. Tried different things. But finally conda install opencv solved the issue for me.
I am having trouble running a python script file that contains import opencv command. Upon running the file, it gives the following error: ImportError: No module named cv2 I then ran pip install python-opencv but it gave Could not find a version that satisfies the requirement python-opencv (from versions: ) No matching distribution found for python-opencv error. Does anyone know what the issue might be? I was able to run this python file at first but I haven't been able to run after that.
0
1
542
0
48,109,501
0
1
0
0
1
false
6
2018-01-05T07:42:00.000
1
3
0
Normalizing data to certain range of values
48,109,228
0.066568
python,normalize
You can use sklearn.preprocessing for a lot of types of pre-processing tasks including normalization.
I am a new in Python, is there any function that can do normalizing a data? For example, I have set of list in range 0 - 1 example : [0.92323, 0.7232322, 0,93832, 0.4344433] I want to normalize those all values to range 0.25 - 0.50 Thank you,
0
1
18,367
0
48,117,192
0
0
0
0
1
true
1
2018-01-05T14:37:00.000
5
1
0
How to traverse a sorted set in Redis in reverse order using zscan?
48,115,753
1.2
python,redis,iterator,redis-py
Scanning the Sorted Set with an iterator does not guarantee any order. Use ZREVRANGEBYSCORE for that.
I have a sorted set in Redis with priorities starting from 0 up to 3. I would like to traverse this sorted set from highest to lowest priority using the python iterator zscan_iter. However, using zscan_iter gives me the items starting from 0. Is there a way to reverse the order? Unfortunately, reverse() only works on iterators and not on python generators. I see two solutions: Use negative priorities (so instead of 3 use -3) Paginate through slices of keys using ZREVRANGEBYSCORE, however I would prefer to use an iterator. Are there any other ways of doing this?
0
1
884
0
48,118,131
0
0
0
0
1
false
1
2018-01-05T15:21:00.000
0
2
0
Does convolution kernel need to be designed in CNN (Convolutional Neural Networks)?
48,116,484
0
python,neural-network,keras,kernel,conv-neural-network
The actual kernel values are learned during the learning process, that's why you only need to set the number of kernels and their size. What might be confusing is that the learned kernel values actually mimic things like Gabor and edge detection filters. These are generic to many computer vision applications, but instead of being engineered manually, they are learned from a big classification dataset (like ImageNet). Also the kernel values are part of a feature hierarchy that can be used directly as features for a variety of computer vision problems. In that terms they are also generic.
I am new to Convolutional Neural Networks. I am reading some tutorial and testing some sample codes using Keras. To add a convolution layer, basically I just need to specify the number of kernels and the size of the kernel. My question is what each kernel looks like? Are they generic to all computer vision applications?
0
1
605