<p dir="auto">I was trying this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="for _ in trange(20):
    Q = qdmat.dot(dqmat.dot(Q))
    csr_topn(Q, 10)
    Normalizer(norm=&quot;l2&quot;, copy=False).fit_transform(Q)
    steps.append(Q[select_indexes])"><pre class="notranslate"><code class="notranslate">for _ in trange(20):
    Q = qdmat.dot(dqmat.dot(Q))
    csr_topn(Q, 10)
    Normalizer(norm="l2", copy=False).fit_transform(Q)
    steps.append(Q[select_indexes])
</code></pre></div>
<p dir="auto">but get this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ValueError                                Traceback (most recent call last)
&lt;ipython-input-5-772329bf5896&gt; in &lt;module&gt;()
      8     Q = qdmat.dot(dqmat.dot(Q))
      9     csr_topn(Q, 10)
---&gt; 10     Normalizer(norm=&quot;l1&quot;, copy=False).fit_transform(Q)
     11     steps.append(Q[select_indexes])
     12 

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/base.py in fit_transform(self, X, y, **fit_params)
    515         if y is None:
    516             # fit method of arity 1 (unsupervised transformation)
--&gt; 517             return self.fit(X, **fit_params).transform(X)
    518         else:
    519             # fit method of arity 2 (supervised transformation)

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/data.py in transform(self, X, y, copy)
   1529         copy = copy if copy is not None else self.copy
   1530         X = check_array(X, accept_sparse='csr')
-&gt; 1531         return normalize(X, norm=self.norm, axis=1, copy=copy)
   1532 
   1533 

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/data.py in normalize(X, norm, axis, copy, return_norm)
   1420                                       &quot;or norm 'l2'&quot;)
   1421         if norm == 'l1':
-&gt; 1422             inplace_csr_row_normalize_l1(X)
   1423         elif norm == 'l2':
   1424             inplace_csr_row_normalize_l2(X)

sklearn/utils/sparsefuncs_fast.pyx in sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l1()

sklearn/utils/sparsefuncs_fast.pyx in sklearn.utils.sparsefuncs_fast._inplace_csr_row_normalize_l1()

ValueError: Buffer dtype mismatch, expected 'int' but got 'long'"><pre class="notranslate"><code class="notranslate">ValueError                                Traceback (most recent call last)
&lt;ipython-input-5-772329bf5896&gt; in &lt;module&gt;()
      8     Q = qdmat.dot(dqmat.dot(Q))
      9     csr_topn(Q, 10)
---&gt; 10     Normalizer(norm="l1", copy=False).fit_transform(Q)
     11     steps.append(Q[select_indexes])
     12 

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/base.py in fit_transform(self, X, y, **fit_params)
    515         if y is None:
    516             # fit method of arity 1 (unsupervised transformation)
--&gt; 517             return self.fit(X, **fit_params).transform(X)
    518         else:
    519             # fit method of arity 2 (supervised transformation)

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/data.py in transform(self, X, y, copy)
   1529         copy = copy if copy is not None else self.copy
   1530         X = check_array(X, accept_sparse='csr')
-&gt; 1531         return normalize(X, norm=self.norm, axis=1, copy=copy)
   1532 
   1533 

/search/odin/tensorflow/lihengchao/anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/data.py in normalize(X, norm, axis, copy, return_norm)
   1420                                       "or norm 'l2'")
   1421         if norm == 'l1':
-&gt; 1422             inplace_csr_row_normalize_l1(X)
   1423         elif norm == 'l2':
   1424             inplace_csr_row_normalize_l2(X)

sklearn/utils/sparsefuncs_fast.pyx in sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l1()

sklearn/utils/sparsefuncs_fast.pyx in sklearn.utils.sparsefuncs_fast._inplace_csr_row_normalize_l1()

ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
</code></pre></div>
<p dir="auto">the csr_matrix Q 's size is</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;178726542x2000000 sparse matrix of type '&lt;class 'numpy.float32'&gt;'
	with 1570091377 stored elements in Compressed Sparse Row format&gt;"><pre class="notranslate"><code class="notranslate">&lt;178726542x2000000 sparse matrix of type '&lt;class 'numpy.float32'&gt;'
	with 1570091377 stored elements in Compressed Sparse Row format&gt;
</code></pre></div>
<p dir="auto">my os: Linux version 2.6.32-504.23.4.el6.x86_64<br>
my python : Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:09:58)<br>
my scipy: 0.19.0<br>
my sklearn:0.19.0</p>
<p dir="auto">In scipy master (to be released as 0.14), scipy <a href="https://github.com/scipy/scipy/blob/master/doc/release/0.14.0-notes.rst#scipysparse-improvements">sparse matrices can now be indexed with 64 bit integers</a>.</p>
<p dir="auto">This means that we will probably need to use fused types for <code class="notranslate">indptr</code> and <code class="notranslate">indices</code> arrays whenever we deal with CSC or CSR datastructures in our Cython code base.</p>
<p dir="auto"><strong>Edit:</strong> by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/rth/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/rth">@rth</a> on Nov 2017 to add the status of support for 64 bit CSR indices  in different parts of the code, as discussed in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="29433687" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/2969" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/2969/hovercard?comment_id=309400363&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/issues/2969#issuecomment-309400363">#2969 (comment)</a></p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> preprocessing_normalize[l1-False]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> preprocessing_normalize[l1-True]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> preprocessing_normalize[l2-False]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> preprocessing_normalize[l2-True]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> decomposition_truncatedsvd[randomized]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> decomposition_truncatedsvd[arpack]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> decomposition_nmf[cd]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> decomposition_nmf[mu]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_logisticregression[liblinear-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[modified_huber-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[squared_hinge-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[squared_hinge-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[squared_hinge-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[perceptron-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[perceptron-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[perceptron-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_loss-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_loss-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_loss-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[huber-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[huber-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[huber-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[epsilon_insensitive-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[epsilon_insensitive-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[epsilon_insensitive-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_epsilon_insensitive-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_epsilon_insensitive-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdregressor[squared_epsilon_insensitive-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> linear_model_estimator[linear_model.LinearRegression]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> linear_model_estimator[linear_model.ElasticNet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_estimator[svm.LinearSVC]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_logisticregression[liblinear-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[log-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[log-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[log-elasticnet]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[modified_huber-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[modified_huber-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_estimator[svm.SVC]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> linear_model_estimator[tree.DecisionTreeClassifier]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> linear_model_logisticregression[newton-cg-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> linear_model_logisticregression[lbfgs-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_logisticregression[sag-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[hinge-l1]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[hinge-l2]</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> linear_model_sgdclassifier[hinge-elasticnet]</li>
</ul>