All-pairs shortest paths (PostgreSQL)

All-pairs shortest paths (PostgreSQL)

Floyd Warshall Algorithm is Θ(V3)
Johnson’s algorithm O(V2log V + VE) . Johnson’s algorithm uses both Dijkstra and Bellman-Ford as subroutines

Dijkstra’s Single Source shortest path algorithm: O(V*VLogV) time. So using Dijkstra’s single source shortest path seems to be a better option than Floyd Warshell, but the problem with Dijkstra’s algorithm is, it doesn’t work for negative weight edge.

 

sudo apt-get install postgresql-9.5-postgis-scripts
psql -d yourdbname -c "CREATE EXTENSION postgis;"
tf+Keras Note

tf+Keras Note

when load model weight,

ValueError: You are trying to load a weight file containing 4 layers into a model with 0 layers.

The problem is the batchnorm. This layer wasn’t there before, so keras is complaining that the model isn’t the same.

If you really want to load weights into a different model, use model.load_weights(..., by_name=True)and ensure that the layers have the same names before and after.

Py Note

Py Note

1. To get the week number

import pandas as pd
time_str = '2019-09-30T13:55:26'
pd.Timestamp(time_str[0:10]).week

2. ImportError: Cannot load backend ‘TkAgg’ which requires the ‘tk’ interactive framework, as ‘headless’ is currently running

to restart my kernel, import the following first:

import matplotlib
matplotlib.use('TKAgg')

Then,

import matplotlib.pyplot as plt

3. Invalidity of geometry when using osmnx.footprints.py

https://github.com/gboeing/osmnx/blob/5176d4a2f86fd2adaf523d3d9bd0bed9b9b1d6ec/osmnx/footprints.py

4. contextily

where is add_basemap():

contextily.plotting.add_basemap()

https://github.com/darribas/contextily/blob/master/contextily/plotting.py

5. geocube

geopandas geometry conversion

https://github.com/corteva/geocube

conda install -c conda-forge geocube

error ‘MergeAlg’

conda install -c conda-forge rasterio

6. upgrade spyder v3 to v4

conda install pyqt=5.6 (or conda install pyqt=5.9.2?)

conda install spyder=4.0.1

conda upgrade –all (do not use conda upgrade pyqt directly )

https://github.com/spyder-ide/spyder/issues/7250

when:

ImportError: cannot import name 'secure_write' 

pip install –upgrade jupyter_client

 

Configuring python extension for NL

Configuring python extension for NL

Configuring:
1.  python=>Configure=>
python3=/path/to/python3
python2=/path/to/python2

1. If you use virtualenv or Conda, simply specify the path of the Python executable in the environment you wish to use:

py:setup “/path/to/myenv/bin/python”

or:
py:setup py:python ; if your code works with either Python 2 or 3
py:setup py:python3 ; for Python 3
py:setup py:python2 ; for Python 2

 

 

Set variables:

py:set “Python_Var_Name” NLogo_Var_Name

z.B.

py:set “state_dims” length inputs
py:set “hl_size” 36

 

AutoKeras

AutoKeras

Auto-Keras is an open source software library for automated machine learning (AutoML). It is developed by DATA Lab at Texas A&M University and community contributors. The ultimate goal of AutoML is to provide easily accessible deep learning tools to domain experts with limited data science or machine learning background. Auto-Keras provides functions to automatically search for architecture and hyperparameters of deep learning models.

https://github.com/keras-team/autokeras

 

mnist autokeras’ version

from keras.datasets import mnist
from autokeras.image_classifier import ImageClassifier

if __name__ == '__main__':
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.reshape(x_train.shape + (1,))
    x_test = x_test.reshape(x_test.shape + (1,))

    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
    clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
    y = clf.evaluate(x_test, y_test)
    print(y * 100)
React-Native笔记

React-Native笔记

1. 搭建环境
https://reactnative.cn/docs/0.41/getting-started.html
总结:模拟器还是Genymotion好用

2. 实例学习-小明找厕所
https://github.com/liumingmusic/react-native-full-example

下载:git clone https://github.com/liumingmusic/react-native_toiletApp.git
安装:cd toilet –> npm install –> react-native run-ios(run-android)

win 10上遇到问题:

FAILURE: Build failed with an exception.

* Where:
Build file ‘D:\MU\react-native_toiletApp\toilet\android\app\build.gradle’ line: 110

* What went wrong:
A problem occurred evaluating project ‘:app’.
> Could not find property ‘MYAPP_RELEASE_STORE_PASSWORD’ on SigningConfig_Decorated{name=release, storeFile=D:\MU\react-native_toiletApp\toilet\android\app\my-release-key.keystore, storePassword=null, keyAlias=null, keyPassword=null, storeType=D:\MU\react-native_toiletApp\toilet\android\app\my-release-key.keystore}.

* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

BUILD FAILED

Total time: 10.644 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

 

原因:gradle properties设置不正确,因此release app时出错

Could not find property ‘MYAPP_RELEASE_STORE_PASSWORD’

This is caused by the first parameter of signing configuration in build.gradle file:

storeFile file(MYAPP_RELEASE_STORE_FILE)

解决方法:

需要在../android/gradle.properties中指定参数在. 在 Windows OS正确设置如下:

MYAPP_RELEASE_STORE_FILE=KEYSTORE_NAME.keystore
MYAPP_RELEASE_KEY_ALIAS=YOUR_ALIAS
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****

参见:http://10minbasics.com/react-native-could-not-find-property-myapp_release_store_file/