Thursday 31 December 2020

keras 5 predict if housing price is above median price 2

 
predict house value from unknown dataset with the trained model. (above average = 1, below average = 0)

#house.py
#train on GPU
pysical_devices = tf.config.experimental.list_physical_devices('GPU')
#print("Num GPUs Available: ", len(pysical_devices))
tf.config.experimental.set_memory_growth(pysical_devices[0], True)

#load model
model = load_model('models/house.h5')

#create test samples that are different from data samples
test_samples = [
    [10000, 6, 5, 0, 1, 0, 2, 5, 0, 500],
    [12000, 7, 5, 1, 1, 1, 3, 7, 0, 600],
    [11000, 7, 5, 0, 1, 1, 3, 6, 0, 550],
    [11000, 6, 5, 0, 1, 1, 3, 6, 0, 550],
]
test_samples = np.array(test_samples)
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_test_samples = scaler.fit_transform(test_samples)
print(scaled_test_samples)
#prediction
predictions = model.predict(x=scaled_test_samples, batch_size=32, verbose=1)

#predicted output index
rounded_predictions = np.argmax(predictions, axis=-1)
print(rounded_predictions)

-------------------------------------
#logs
#scaled input
[[0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [1.  1.  0.  1.  0.  1.  1.  1.  0.  1. ]
 [0.5 1.  0.  0.  0.  1.  1.  0.5 0.  0.5]
 [0.5 0.  0.  0.  0.  1.  1.  0.5 0.  0.5]]

#output
[0 1 1 0]

reference:

keras 4 predict if housing price is above median price 1

goal is to predict if house value is above or below average based on 10 types of measurements

#house.py
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Activation, Dense, Dropout
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.metrics import categorical_crossentropy
from tensorflow.keras import regularizers
import numpy as np
from random import randint
from sklearn.utils import shuffle
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import confusion_matrix
import itertools
import matplotlib.pyplot as plt
from tensorflow.keras.models import load_model
import pandas as pd
from sklearn.model_selection import train_test_split

df = pd.read_csv('data/housepricedata.csv')
#print(df.head())

dataset = df.values
#print(dataset)

samples = dataset[0:1000, 0:10]
labels = dataset[0:1000, 10]
samples, labels = shuffle(samples, labels)

#scale input between 0, 1
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_train_samples = scaler.fit_transform(samples)

#split dataset 70% training, 30% testing
train_samples, test_samples, train_labels, test_labels = train_test_split(scaled_train_samples, labels, test_size=0.3)
print(train_samples.shape, train_labels.shape, test_labels.shape, test_labels.shape)

#train on GPU
pysical_devices = tf.config.experimental.list_physical_devices('GPU')
#print("Num GPUs Available: ", len(pysical_devices))
tf.config.experimental.set_memory_growth(pysical_devices[0], True)

#create model
model = Sequential([
    Dense(units=32, input_shape=(10,), activation='relu'),
    Dense(units=32, activation='relu'),
    Dense(units=32, activation='relu'),
    Dense(units=2, activation='softmax')
])
model.summary()

#training & validation
model.compile(optimizer=Adam(learning_rate=0.0001), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(x=train_samples, y=train_labels, validation_split=0.1, batch_size=32, epochs=200, shuffle=True, verbose=2)

#save model
#model.save('models/house.h5')

#prediction
predictions = model.predict(x=test_samples, batch_size=32, verbose=1)

#predicted output index
rounded_predictions = np.argmax(predictions, axis=-1)

#visualize prediction accuracy - confusion matrix
cm = confusion_matrix(y_true=test_labels, y_pred=rounded_predictions)

def plot_confusion_matrix(cm, classes,
                        normalize=False,
                        title='Confusion matrix',
                        cmap=plt.cm.Blues):
    """
    This function prints and plots the confusion matrix.
    Normalization can be applied by setting `normalize=True`.
    """
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(classes))
    plt.xticks(tick_marks, classes, rotation=45)
    plt.yticks(tick_marks, classes)

    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
        print("Normalized confusion matrix")
    else:
        print('Confusion matrix, without normalization')

    print(cm)

    thresh = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        plt.text(j, i, cm[i, j],
            horizontalalignment="center",
            color="white" if cm[i, j] > thresh else "black")

    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    plt.show()

cm_plot_labels = ['below avg', 'above_avg']

plot_confusion_matrix(cm=cm, classes=cm_plot_labels, title='Confusion Matrix')

----------------------------------------
#logs
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
dense (Dense)                (None, 32)                352
_________________________________________________________________
dense_1 (Dense)              (None, 32)                1056
_________________________________________________________________
dense_2 (Dense)              (None, 32)                1056
_________________________________________________________________
dense_3 (Dense)              (None, 2)                 66
=================================================================
Total params: 2,530
Trainable params: 2,530
Non-trainable params: 0
_________________________________________________________________
2020-12-31 16:26:55.838065: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (register
ed 2)
Epoch 1/200
2020-12-31 16:26:56.160440: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2020-12-31 16:26:56.347504: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
20/20 - 1s - loss: 0.6870 - accuracy: 0.5032 - val_loss: 0.6569 - val_accuracy: 0.5857
Epoch 2/200
20/20 - 0s - loss: 0.6803 - accuracy: 0.5032 - val_loss: 0.6507 - val_accuracy: 0.5857
Epoch 3/200
20/20 - 0s - loss: 0.6741 - accuracy: 0.5032 - val_loss: 0.6449 - val_accuracy: 0.5857
Epoch 4/200
20/20 - 0s - loss: 0.6686 - accuracy: 0.5032 - val_loss: 0.6394 - val_accuracy: 0.5857
Epoch 5/200
20/20 - 0s - loss: 0.6636 - accuracy: 0.5032 - val_loss: 0.6352 - val_accuracy: 0.5857
...
Epoch 198/200
20/20 - 0s - loss: 0.2478 - accuracy: 0.9048 - val_loss: 0.2351 - val_accuracy: 0.8857
Epoch 199/200
20/20 - 0s - loss: 0.2472 - accuracy: 0.9048 - val_loss: 0.2351 - val_accuracy: 0.8857
Epoch 200/200
20/20 - 0s - loss: 0.2467 - accuracy: 0.9048 - val_loss: 0.2313 - val_accuracy: 0.9000
10/10 [==============================] - 0s 665us/step
Confusion matrix, without normalization
[[143  13]
 [ 17 127]]

Wednesday 30 December 2020

Marvel's Avengers

加拿大要求持3天内阴性检测报告登机

 加拿大要求所有乘客在返回前拿到阴性检测报告!

由于近段时间以来,加拿大新增确诊病例不断攀升,导致政府不得不采取更多措施抑制疫情恶化。

就在今天(12月30日),加拿大政府间事务部长Dominic LeBlanc突然宣布了一条与华人息息相关的新规:要求所有乘客在抵达加拿大之前拿到COVID-19阴性检测报告!并且原有的14天入境隔离的规定仍然保留。

“除非绝对必要,否则我们强烈建议您不要出国旅行。”

据报道,加拿大的旅行限制将很快通知航空公司实施新规,要求乘客在登机前3天内进行新冠病毒检测,并且需持有阴性检测报告才能登机。

keras 3 save/load model

//main.py
from tensorflow.keras.models import load_model

"""
#create model
model = Sequential([
    Dense(units=16, input_shape=(1,), activation='relu'),
    Dense(units=32, activation='relu'),
    Dense(units=2, activation='softmax')
])
model.summary()

#training & validation
model.compile(optimizer=Adam(learning_rate=0.0001), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(x=scaled_train_samples, y=train_lables, validation_split=0.1, batch_size=10, epochs=30, shuffle=True, verbose=2)

#save model
model.save('models/model1.h5')
"""

#load model
model = load_model('models/model1.h5')
model.summary()
print( model.get_weights())
print(model.optimizer) 

------------------------------
#logs
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
dense (Dense)                (None, 16)                32
_________________________________________________________________
dense_1 (Dense)              (None, 32)                544
_________________________________________________________________
dense_2 (Dense)              (None, 2)                 66
=================================================================
Total params: 642
Trainable params: 642
Non-trainable params: 0
_________________________________________________________________
[array([[ 0.26625147, -0.30418316, -0.13632423, -0.4079098 , -0.08543348,
         0.5374129 ,  0.4584436 , -0.28098437, -0.52589685, -0.4887119 ,
         0.01660078, -0.10933313, -0.04969841, -0.10267085,  0.7305957 ,
         0.38774747]], dtype=float32), array([-0.09283859,  0.        ,  0.        ,  0.        ,  0.        ,
       -0.09529305, -0.13439798,  0.        ,  0.        ,  0.        ,
        0.20418786,  0.        ,  0.        ,  0.        , -0.13027988,
       -0.1161219 ], dtype=float32), array([[ 0.26004615, -0.31933463,  0.21335247,  0.06417851, -0.12653175,
        -0.40698838, -0.2899054 , -0.3321916 , -0.51734823,  0.2656369 ,
         0.25500387, -0.23773687,  0.09429104, -0.5213961 ,  0.5374189 ,
         0.47588807,  0.15414259, -0.26182094, -0.06989337,  0.16001046,
         0.05894524,  0.5102477 ,  0.10094702, -0.20431465, -0.03044271,
        -0.25523925, -0.40259373,  0.07096949, -0.3661572 ,  0.40184933,
        -0.20758483,  0.01585205],
       [ 0.2500454 , -0.31888163,  0.12653747, -0.34026104,  0.207423  ,
         0.22553   , -0.21539871,  0.10445303, -0.30555665, -0.28052825,
         0.0283457 ,  0.21818611,  0.24136344, -0.13501498,  0.01192671,
        -0.10412639,  0.2694293 , -0.22594748, -0.06913146, -0.30933705,
         0.00475213, -0.09345153,  0.20352694, -0.163133  ,  0.13384211,
        -0.19982849, -0.28636962, -0.31544378,  0.1858199 ,  0.1552572 ,
         0.01639351,  0.2738203 ],
     ...
       [ 0.50497067, -0.30627   ],
       [ 0.3936801 , -0.17796172],
       [-0.65509355,  0.02540744],
       [-0.10199237, -0.04108612],
       [ 0.7816102 , -0.721409  ]], dtype=float32), array([ 0.09544881, -0.09544882], dtype=float32)]
<tensorflow.python.keras.optimizer_v2.adam.Adam object at 0x00000145A451F8E0>

loaded model prediction on test data set is still accurate
reference:

Tuesday 29 December 2020

想实现财富自由吗?

keras 2 build & test simple sequential model

#pycharm
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Activation, Dense
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.metrics import categorical_crossentropy
import numpy as np
from random import randint
from sklearn.utils import shuffle
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import confusion_matrix
import itertools
import matplotlib.pyplot as plt

#create training dataset
train_lables = []
train_samples = []

for i in range(50):
    random_younger = randint(13, 64)
    train_samples.append(random_younger)
    train_lables.append(1)

    random_older = randint(65, 100)
    train_samples.append(random_older)
    train_lables.append(0)

for i in range(1000):
    random_younger = randint(13, 64)
    train_samples.append(random_younger)
    train_lables.append(0)

    random_older = randint(65, 100)
    train_samples.append(random_older)
    train_lables.append(1)

"""
for i in train_samples:
    print(i)

for i in train_lables:
    print(i)
"""

train_lables = np.array(train_lables)
train_samples = np.array(train_samples)
train_lables, train_samples = shuffle(train_lables,train_samples)

#scale input between 0, 1
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_train_samples = scaler.fit_transform(train_samples.reshape(-1, 1))

"""
for i in scaled_train_samples:
    print(i)
"""
#train on GPU
pysical_devices = tf.config.experimental.list_physical_devices('GPU')
#print("Num GPUs Available: ", len(pysical_devices))
tf.config.experimental.set_memory_growth(pysical_devices[0], True)

#create model
model = Sequential([
    Dense(units=16, input_shape=(1,), activation='relu'),
    Dense(units=32, activation='relu'),
    Dense(units=2, activation='softmax')
])
model.summary()

#training & validation
model.compile(optimizer=Adam(learning_rate=0.0001), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(x=scaled_train_samples, y=train_lables, validation_split=0.1, batch_size=10, epochs=30, shuffle=True, verbose=2)

#create test set
test_labels = []
test_samples = []

for i in range(10):
    random_younger = randint(13, 64)
    test_samples.append(random_younger)
    test_labels.append(1)

    random_older = randint(65, 100)
    test_samples.append(random_older)
    test_labels.append(0)

for i in range(200):
    random_younger = randint(13, 64)
    test_samples.append(random_younger)
    test_labels.append(0)

    random_older = randint(65, 100)
    test_samples.append(random_older)
    test_labels.append(1)

test_labels = np.array(test_labels)
test_samples = np.array(test_samples)
test_labels, test_samples = shuffle(test_labels,test_samples)

scaled_test_samples = scaler.fit_transform(test_samples.reshape(-1, 1))

#prediction - [category1 probability, category 2 probability,...]
predictions = model.predict(x=scaled_test_samples, batch_size=10, verbose=0)

"""
for i in predictions:
    print(i)
"""

#predicted output index
rounded_predictions = np.argmax(predictions, axis=-1)

"""
for i in rounded_predictions:
    print(i)
"""

#visualize prediction accuracy - confusion matrix
cm = confusion_matrix(y_true=test_labels, y_pred=rounded_predictions)

def plot_confusion_matrix(cm, classes,
                        normalize=False,
                        title='Confusion matrix',
                        cmap=plt.cm.Blues):
    """
    This function prints and plots the confusion matrix.
    Normalization can be applied by setting `normalize=True`.
    """
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(classes))
    plt.xticks(tick_marks, classes, rotation=45)
    plt.yticks(tick_marks, classes)

    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
        print("Normalized confusion matrix")
    else:
        print('Confusion matrix, without normalization')

    print(cm)

    thresh = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        plt.text(j, i, cm[i, j],
            horizontalalignment="center",
            color="white" if cm[i, j] > thresh else "black")

    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    plt.show()

cm_plot_labels = ['category_1', 'category 2']

plot_confusion_matrix(cm=cm, classes=cm_plot_labels, title='Confusion Matrix')

----------------------------
#logs
2020-12-29 13:41:17.573502: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
dense (Dense)                (None, 16)                32
_________________________________________________________________
dense_1 (Dense)              (None, 32)                544
_________________________________________________________________
dense_2 (Dense)              (None, 2)                 66
=================================================================
Total params: 642
Trainable params: 642
Non-trainable params: 0
_________________________________________________________________
2020-12-29 13:41:17.627830: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (register
ed 2)
Epoch 1/30
2020-12-29 13:41:17.887594: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2020-12-29 13:41:18.077645: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
189/189 - 1s - loss: 0.7641 - accuracy: 0.4254 - val_loss: 0.7218 - val_accuracy: 0.3952
Epoch 2/30
189/189 - 0s - loss: 0.7031 - accuracy: 0.3413 - val_loss: 0.6832 - val_accuracy: 0.4762
Epoch 3/30
189/189 - 0s - loss: 0.6598 - accuracy: 0.5667 - val_loss: 0.6546 - val_accuracy: 0.5762
Epoch 4/30
189/189 - 0s - loss: 0.6252 - accuracy: 0.6730 - val_loss: 0.6264 - val_accuracy: 0.6619
Epoch 5/30
189/189 - 0s - loss: 0.5920 - accuracy: 0.7275 - val_loss: 0.5984 - val_accuracy: 0.6952
Epoch 6/30
189/189 - 0s - loss: 0.5594 - accuracy: 0.7677 - val_loss: 0.5698 - val_accuracy: 0.7381
Epoch 7/30
189/189 - 0s - loss: 0.5285 - accuracy: 0.7884 - val_loss: 0.5427 - val_accuracy: 0.7619
Epoch 8/30
189/189 - 0s - loss: 0.4994 - accuracy: 0.8233 - val_loss: 0.5167 - val_accuracy: 0.7857
Epoch 9/30
189/189 - 0s - loss: 0.4716 - accuracy: 0.8381 - val_loss: 0.4915 - val_accuracy: 0.8238
Epoch 10/30
189/189 - 0s - loss: 0.4457 - accuracy: 0.8571 - val_loss: 0.4676 - val_accuracy: 0.8476
Epoch 11/30
189/189 - 0s - loss: 0.4219 - accuracy: 0.8714 - val_loss: 0.4461 - val_accuracy: 0.8571
Epoch 12/30
189/189 - 0s - loss: 0.4002 - accuracy: 0.8847 - val_loss: 0.4262 - val_accuracy: 0.8619
Epoch 13/30
189/189 - 0s - loss: 0.3807 - accuracy: 0.8873 - val_loss: 0.4085 - val_accuracy: 0.9000
Epoch 14/30
189/189 - 0s - loss: 0.3633 - accuracy: 0.9000 - val_loss: 0.3931 - val_accuracy: 0.9000
Epoch 15/30
189/189 - 0s - loss: 0.3481 - accuracy: 0.9011 - val_loss: 0.3795 - val_accuracy: 0.9000
Epoch 16/30
189/189 - 0s - loss: 0.3353 - accuracy: 0.9063 - val_loss: 0.3675 - val_accuracy: 0.9095
Epoch 17/30
189/189 - 0s - loss: 0.3235 - accuracy: 0.9116 - val_loss: 0.3567 - val_accuracy: 0.9143
Epoch 18/30
189/189 - 0s - loss: 0.3137 - accuracy: 0.9148 - val_loss: 0.3475 - val_accuracy: 0.9143
Epoch 19/30
189/189 - 0s - loss: 0.3051 - accuracy: 0.9180 - val_loss: 0.3396 - val_accuracy: 0.9238
Epoch 20/30
189/189 - 0s - loss: 0.2981 - accuracy: 0.9243 - val_loss: 0.3328 - val_accuracy: 0.9238
Epoch 21/30
189/189 - 0s - loss: 0.2918 - accuracy: 0.9265 - val_loss: 0.3270 - val_accuracy: 0.9238
Epoch 22/30
189/189 - 0s - loss: 0.2866 - accuracy: 0.9296 - val_loss: 0.3223 - val_accuracy: 0.9238
Epoch 23/30
189/189 - 0s - loss: 0.2822 - accuracy: 0.9323 - val_loss: 0.3175 - val_accuracy: 0.9381
Epoch 24/30
189/189 - 0s - loss: 0.2782 - accuracy: 0.9339 - val_loss: 0.3136 - val_accuracy: 0.9381
Epoch 25/30
189/189 - 0s - loss: 0.2748 - accuracy: 0.9323 - val_loss: 0.3102 - val_accuracy: 0.9381
Epoch 26/30
189/189 - 0s - loss: 0.2717 - accuracy: 0.9392 - val_loss: 0.3070 - val_accuracy: 0.9381
Epoch 27/30
189/189 - 0s - loss: 0.2691 - accuracy: 0.9370 - val_loss: 0.3042 - val_accuracy: 0.9381
Epoch 28/30
189/189 - 0s - loss: 0.2669 - accuracy: 0.9381 - val_loss: 0.3017 - val_accuracy: 0.9381
Epoch 29/30
189/189 - 0s - loss: 0.2647 - accuracy: 0.9370 - val_loss: 0.2993 - val_accuracy: 0.9381
Epoch 30/30
189/189 - 0s - loss: 0.2632 - accuracy: 0.9407 - val_loss: 0.2971 - val_accuracy: 0.9381
Confusion matrix, without normalization
[[195  15]
 [ 10 200]]
reference:

apk downloader

https://apkcombo.com/en-ca/apk-downloader/

use dd to wipe drive

DD can be used to overwrite a disk. Doesn't matter it has protected partition or not. Replace the X for the disk to be wiped. Dd overwrites the disk with zero and allows us to format the device. 

//ubuntu terminal
//list disk
sudo lsblk

//wipe disk
sudo dd if=/dev/urandom of=/dev/sdX bs=4k

//watch dd progress
//open another terminal
sudo watch -n5 'sudo kill -USR1 $(pgrep ^dd)'

reference:

Monday 28 December 2020

use dd to clone drive

//ubuntu terminal
//list disk
sudo lsblk

//clone disk
sudo dd if = /dev/sda of = /dev/sdb

“if” represents inputfile, and “of” represents output file. So the exact copy of /dev/sda will be available in /dev/sdb.

//watch dd progress
//open another terminal
sudo watch -n5 'sudo kill -USR1 $(pgrep ^dd)'

reference:
list disk

dd

monitor dd

Sunday 27 December 2020

What’s the difference between SATA, PCIe and NVMe?

NVMe, AHCI and IDE are transfer protocols (languages). They run on top of transfer interfaces such as PCIe or SATA (spoken, written).

SATA is the market incumbent and dominant interface for connecting an SSD to the PC. It employs the command protocol AHCI (it also supports IDE) which was built with slower spinning disks in mind rather than flash memory. SATA transfer rates begin at 150 MB/s and max out at 600 MB/s for third generation technology. For most consumers this is adequate.

PCIe (Peripheral Component Interconnect Express ) supersedes SATA as the latest high bandwidth interface that connects hardware: CPUs, GPUs, SSDs, sound cards, network cards, and other PCIe cards. Entry level PCIe 3.0 SSD speeds are two to three times faster than the older generation of SATA 3.0 SSDs mainly due to the number of channels contained by each to transfer data (roughly 10 for SATA and 25 for PCIe). However, depending on usage, real world benchmarks may not reflect this massive gain due to bottlenecks elsewhere in the PC. Here is a comparison between the two market leading NVMe and SATA SSDs: Samsung 970 Pro vs 860 Pro.

NVMe is the latest high performance and optimized protocol which supersedes AHCI and compliments PCIe technology. It offers an optimised command and completion path for use with NVMe based storage. It was developed by a consortium of manufacturers specifically for SSDs to overcome the speed bottleneck imposed by the older SATA connection. It is akin to a more efficient language between storage device and PC: one message needs to be sent for a 4GB transfer instead of two, NVMe can handle 65,000 queues of data each with 65,000 commands, instead of one queue that with the capacity for 32 commands, and it only has seven major commands (read, write, flush etc). As well as delivering better throughput NVMe offers reduced latency. NVMe will be the protocol of choice for the next generation of storage technologies such as 3D XPoint.

PCIe 4.0 refers to the fourth generation of PCIe interface which has double the bandwidth (64GB/s for a x16 slot) compared to PCIe 3.0 (32GB/s for a x16 slot), which is the usual improvement between PCIe generations. PCIe devices are forward and backward compatible, therefore a PCIe 3.0 SSD will still work on a PCIe 4.0 motherboard and conversely a PCIe 4.0 SSD would work on a PCIe 3.0 motherboard (following a software update), with performance limited by the weaker component. PCIe 4.0 devices such as AMD’s X570 motherboard chipset are coming to market in 2019.

PCIe 5.0 devices are expected to be available in 2020 and will have double of bandwidth of PCIe 4.0 (132GB/s for a x16 slot) as well as other technical enhancements. However, given that 16 lanes of PCIe 3.0 is currently sufficient for the majority of users, demand for PCIe 5.0 in the near future will mostly be driven by super users and data centres, and will co-exist alongside PCIe 4.0 devices.

reference:

Saturday 26 December 2020

keras 1 run tensorflow on gpu

//tensorflow supports 64 bit python version 3.5 - 3.8
//download python 3.8.7

//install visual studio 2017 community
//install c++ reditributable

//install tensorflow
pip install --upgrade pip
pip install tensorflow

//cuda supported nvidia gpu
//download gpu driver

//numpy fails to pass sanity check
pip uninstall numpy
pip install numpy==1.19.3

//tf-nightly-gpu looking for cusolver64_10.dll on a Cuda 11.1.1
revert to install cuda 11.1.0, maybe also install cuda 10.1

//install cuda toolkit 11.1.0
//install cuda tookit 10.1 -maybe needed
//install cudnn for cuda 11.0

//5. restart windows
https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html

//main.py
import tensorflow as tf
#tf.version.VERSION
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

//pycharm terminal
(venv) C:\Users\bob\keras>python main.py
2020-12-27 10:21:57.210710: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2020-12-27 10:23:45.222471: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2020-12-27 10:23:45.375593: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2020-12-27 10:23:46.401095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1060 3GB computeCapability: 6.1
coreClock: 1.7085GHz coreCount: 9 deviceMemorySize: 3.00GiB deviceMemoryBandwidth: 178.99GiB/s
2020-12-27 10:23:46.401228: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2020-12-27 10:23:50.660090: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2020-12-27 10:23:50.660490: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2020-12-27 10:23:52.598990: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2020-12-27 10:23:52.797069: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2020-12-27 10:23:54.320794: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2020-12-27 10:23:54.931670: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2020-12-27 10:23:55.064642: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2020-12-27 10:23:55.064844: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
Num GPUs Available:  1

reference:

Thursday 24 December 2020

lansing trip

expense
nov 16 - driving, dollarama
nov 25 - hard drive, phone
nov 26 - fuel x2, taxi, hotel 
nov 28 - pilot meal
nov 29 - hotel, fuel, pilot meal, taxi
nov 30 - tools, fuel x 2, fedex, pilot meal, hotel
dec 1 - hotel
dec 3 - hotel
dec 4 - hotel, car rental, uber
dec 5 - hotel
dec 6 - phone, hotel, uber x 4, fuel
dec 7 - hotel
dec 9 - hotel
dec 10 - hotel
dec 11 - fedex, hotel
dec 12 - rental car, gas
dec 13 - hotel
dec 15 - hotel
dec 17 - hotel, phone
dec 18 - hotel
dec 19 - hotel, dollar tree, car rental
dec 21 - hotel
dec 23 - hotel, dollar tree
dec 24 - hotel, gas, rental car, fuel
dec 25 - luggage, uber

timesheet
nov 16 - bundle - 8h
nov 26 - ferry to kalamazoo - 12h
nov27 - survey - 12h
nov28 - survey - 12h
nov29 - ferry to flint, survey - 12h
nov30 - fix bad frame - 8h
dec1 - weather down - 8h
dec2 - survey - 10h
dec3 - survey port huron - 10h
dec4 - weather down - 8h
dec5 - weather down - 8h
dec6 - ferry to morristown - 8h
dec7 - waiting for atc approval - 8h
dec8 - waiting for atc approval - 8h
dec9 - weather - 8h
dec10 - survey - 10h
dec 11 - weather - 8h
dec12 - weather -8h
dec13 - survey - 10h
dec14 - weather - 8h
dec 15 - survey - 10h
dec 16 - aircraft maintenance - 8h
dec 17 - aircraft maintenance - 8h
dec 18 - aircraft maintenance - 8h
dec 19 - aircraft maintenance - 8h
dec 20 - aircraft maintenance - 8h
dec 21 - weather - 8h
dec 22 - weather - 8h
dec 23 - survey - 8h
dec 24 - survey - 8h
dec 25 - fly back -8h

Tuesday 22 December 2020

NZXT Gaming PC Build | INTEL i9-10850K | RTX 3080


Total cost of building this PC was $2400 Parts list: (Amazon & Newegg affiliate) NZXT H510 Elite Case https://amzn.to/384Abtb Newegg https://bit.ly/38AhEFF NZXT N7 Z490 Motherboard https://amzn.to/36FEbPO https://www.nzxt.com/products/n7-z490... NZXT C850W Power Supply https://amzn.to/36d8qfN Newegg https://bit.ly/3eTnRgI NZXT Kraken Z63 Liquid Cooler https://amzn.to/329PSMa Newegg https://bit.ly/36q5RXL INTEL i9-10850K CPU https://amzn.to/2TJCCcu Newegg https://bit.ly/3ljAmES Corsair Dominator Platinum RGB 16GB (2x8GB) DDR4 3200 Newegg https://bit.ly/3lpXRMu Corsair Dominator Platinum RGB 32GB (4x8GB) DDR4 3200 https://amzn.to/3fWw98r Nvidia Geforce RTX 3080 1TB WD BLACK SN750 NVMe https://amzn.to/3mS0qaJ Newegg https://bit.ly/2GROPZF 500GB WD BLACK SN750 NVMe https://amzn.to/2HXX3zP Newegg https://bit.ly/32zh07y Antec PSU Extension Cable https://amzn.to/3jOTby3 NZXT AER RGB 2 120mm https://www.nzxt.com/products/aer-rgb-2 NZXT AER RGB 2 120mm https://amzn.to/2GAVrLS NZXT AER RGB 2 140mm https://amzn.to/2TP5X5m Newegg https://bit.ly/3nh7hup

redis tutorial

Saturday 19 December 2020

YYC boarder testing

Steps to follow upon arrival at YYC: 

  1. You must fill in the ArriveCAN app form with your quarantine plan and contact info up to 48 hours in advance as of Nov. 21.  
  2. Complete your customs declaration with the CanBorder eDeclaration app
  3. Complete the International Border Testing Pilot Program questionnaire (this can be done up to five days in advance of arriving).

Visit the Government of Alberta’s website for more information on the program.  

Batch Size in a Neural Network

需求侧改革

Saturday 5 December 2020

九章量子计算机

Concurrency in Go

Sub-1% Mortgage Rates Come to Canada, Courtesy of HSBC

 

A High Ratio Mortgage is a personal mortgage with a down payment of less than 20% of the purchase price. Applications are subject to credit approval. Rate displayed includes a 0.35%  or 0.25% discount off our Special Offer rate and is only available for high ratio residential mortgages.

Thursday 3 December 2020

Wired vs Wireless Security Cameras


golden rule: use wired camera where you can, and consider wireless otherwise.

i9-10900k vs. i7-10700k

 Intel’s Comet Lake flagship, the i9-10900K, is the fastest gaming and desktop CPU currently available.The 10900K also requires a new (Z490) LGA1200 motherboard

19,677 User Benchmarks
Best Bench: 108% Base clock 3.7 GHz, turbo 5.3 GHz (avg)
Worst Bench: 96% Base clock 3.7 GHz, turbo 0.8 GHz (avg)
SPEED RANK: 2nd / 1276

45,594 User Benchmarks
Best Bench: 106% Base clock 3.8 GHz, turbo 5.15 GHz (avg)
Worst Bench: 91% Base clock 3.8 GHz, turbo 0.8 GHz (avg)
SPEED RANK: 7th / 1276

Age
Newest
7 Months7 Months
TDP
Thermal Design Power (TDP)
125 Watts125 Watts
Cores
CPU Processing Cores
10 coresHigher core count.
+25% 
8 cores
Threads
CPU Processing Threads
20 threadsHigher thread count.
+25% 
16 threads
Lithography
Manufacturing process
14 nm14 nm
Base Clock
Base Clock Speed
3.7 GHz3.8 GHz+3%
Turbo Clock
Turbo Clock Speed
5.3 GHz+4%5.1 GHz
64-Core
OC Multi Core Mixed Speed
2126 PtsFaster OC 64-core speed.
+28% 
1666 Pts
64-Core
Avg. Multi Core Mixed Speed
1996 PtsFaster 64-core speed.
+30% 
1541 Pts

reference: