def _dense_to_sparse(batch):
 if isinstance(batch, tuple):
  raise TypeError('Composite batches not supported.')
 assert (not isinstance(batch, list))
 if is_symbolic_batch(batch):
  assert isinstance(batch, theano.tensor.TensorVariable)
  return theano.sparse.csr_from_dense(batch)
 else:
  assert isinstance(batch, np.ndarray), ('type of batch: %s' % type(batch))
  return scipy.sparse.csr_matrix(batch)

def _dense_to_sparse ( batch ) : if isinstance ( batch , tuple ) : raise TypeError ( 'Composite batches not supported.' ) assert ( not isinstance ( batch , list ) ) if is_symbolic_batch ( batch ) : assert isinstance ( batch , theano . tensor . TensorVariable ) return theano . sparse . csr_from_dense ( batch ) else : assert isinstance ( batch , np . ndarray ) , ( 'type of batch: %s' % type ( batch ) ) return scipy . sparse . csr_matrix ( batch )
casts dense batches to sparse batches .