OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable

I had this problem running numpy on an ubuntu server. I got all of the following errors, depending on whether I tried to import numpy in a shell or running my django app: PyCapsule_Import could not import module “datetime” from numpy.core._multiarray_umath import ( OpenBLAS blas_thread_init: pthread_create failed for thread 25 of 32: Resource temporarily unavailable … Read more

How to add command line arguments with flags in Python3?

The python 3 library includes 3 modules for parsing the command line thus nothing extra to add to your setup. The one you should use is argparse import argparse parser = argparse.ArgumentParser() #-db DATABASE -u USERNAME -p PASSWORD -size 20 parser.add_argument(“-db”, “–hostname”, help=”Database name”) parser.add_argument(“-u”, “–username”, help=”User name”) parser.add_argument(“-p”, “–password”, help=”Password”) parser.add_argument(“-size”, “–size”, help=”Size”, type=int) … Read more

Description of TF Lite’s Toco converter args for quantization aware training

You should never need to manually set the quantization stats. Have you tried the post-training-quantization tutorials? https://www.tensorflow.org/lite/performance/post_training_integer_quant Basically they set the quantization options: converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] converter.inference_input_type = tf.uint8 converter.inference_output_type = tf.uint8 Then they pass a “representative dataset” to the converter, so that the converter can run the model a few batches to gather the … Read more

Making Int64 the default integer dtype instead of standard int64 in pandas

You could use a function like this: def nan_ints(df, convert_strings=False, subset=None): types = [“int64”, “float64”] if subset is None: subset = list(df) if convert_strings: types.append(“object”) for col in subset: if df[col].dtype in types: df[col] = ( df[col].astype(float, errors=”ignore”).astype(“Int64″, errors=”ignore”) ) return df It iterates through each column and coverts it to an Int64 if it … Read more

Cannot load backend ‘Qt5Agg’ which requires the ‘qt5’ interactive framework, as ‘headless’ is currently running

This is happening because Google Colab and Jupyter run on virtual environments which do not support GUI outputs as you cannot open new windows through a browser. Running it locally on a code editor(Spyder, or even IDLE) ensures that it can open a new window for the GUI to initialize. For coding the GUI it … Read more

argparse action or type for comma-separated list

The simplest solution is to consider your argument as a string and split. #!/usr/bin/env python3 import argparse parser = argparse.ArgumentParser() parser.add_argument(“–myarg”, type=str) args = parser.parse_args() if args.myarg is not None: args.myarg = [s.strip() for s in args.myarg.split(“,”)] print(args) Result: $ ./toto.py –myarg=abcd,e,fg Namespace(myarg=[‘abcd’, ‘e’, ‘fg’]) $ ./toto.py –myarg=”abcd, e, fg” Namespace(myarg=[‘abcd’, ‘e’, ‘fg’])

Must have equal len keys and value when setting with an iterable

You can use apply to index into leader and exchange values with DatasetLabel, although it’s not very pretty. One issue is that Pandas won’t let us index with NaN. Converting to str provides a workaround. But that creates a second issue, namely, column 9 is of type float (because NaN is float), so 5 becomes … Read more

tech