Skip to content

Instantly share code, notes, and snippets.

Details of liblinar options
-s type : set type of solver (default 1)
for multi-class classification
0 -- L2-regularized logistic regression (primal)
1 -- L2-regularized L2-loss support vector classification (dual)
2 -- L2-regularized L2-loss support vector classification (primal)
3 -- L2-regularized L1-loss support vector classification (dual)
4 -- support vector classification by Crammer and Singer
5 -- L1-regularized L2-loss support vector classification
6 -- L1-regularized logistic regression
class Solution(object):
def copyRandomList(self, head):
if head == None: return None
map_to_copy = {}
node = head
while node != None:
node_copy = RandomListNode(node.label)
map_to_copy[node] = node_copy
node = node.next
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC_RAW, &start);
yourKernelHere();
clock_gettime(CLOCK_MONOTONIC_RAW, &end);
uint64_t delta_us = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
mexPrintf("%d\n",elapsed);
def init_log(path):
log = logging.getLogger()
log.setLevel(logging.INFO)
formatter_cs = logging.Formatter('%(message)s')
cs = logging.StreamHandler(sys.stdout)
cs.setLevel(logging.INFO)
cs.setFormatter(formatter_cs)
log.addHandler(cs)
paperspace@ps23cigeo:~$ source env/tf/bin/activate
(tf) paperspace@ps23cigeo:~$ pip3 install --upgrade tensorflow-gpu
Collecting tensorflow-gpu
Downloading https://files.pythonhosted.org/packages/3b/54/d2ec2e2be34d2ded4432d6ae63933d1e43701772d3e03f4dcb1eeec45e16/tensorflow_gpu-1.7.0-cp36-cp36m-manylinux1_x86_64.whl (256.2MB)
100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 256.2MB 174kB/s
Requirement not upgraded as not directly required: gast>=0.2.0 in ./anaconda3/lib/python3.6/site-packages (from tensorflow-gpu) (0.2.0)
Requirement not upgraded as not directly required: grpcio>=1.8.6 in ./anaconda3/lib/python3.6/site-packages (from tensorflow-gpu) (1.10.0)
Requirement not upgraded as not directly required: numpy>=1.13.3 in ./anaconda3/lib/python3.6/site-packages (from tensorflow-gpu) (1.14.2)
Requirement not upgraded as not directly required: absl-py>=
step = optimizer.apply_gradients(gv1)
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
step = tf.group(step, update_ops)
2018-05-12 03:58:14,268 - t=0.00000000 d=0.00000000 c_train=0.14257702 c_test=1.67667461 a_train=0.96183594 a_test=0.63510000
2018-05-12 03:58:28,206 - t=0.01010101 d=69.68927002 c_train=0.16672799 c_test=1.66016670 a_train=0.95085937 a_test=0.64070000
2018-05-12 03:58:41,994 - t=0.02020202 d=136.84338379 c_train=0.19074906 c_test=1.66823967 a_train=0.94281250 a_test=0.64030000
2018-05-12 03:58:55,986 - t=0.03030303 d=201.56515503 c_train=0.19338821 c_test=1.68888761 a_train=0.94062500 a_test=0.64100000
2018-05-12 03:59:09,845 - t=0.04040404 d=263.95980835 c_train=0.19399030 c_test=1.71490045 a_train=0.93816406 a_test=0.63700000
2018-05-12 03:59:23,743 - t=0.05050505 d=324.13366699 c_train=0.18839046 c_test=1.74203128 a_train=0.94328125 a_test=0.63700000
2018-05-12 03:59:37,778 - t=0.06060606 d=382.19277954 c_train=0.17882024 c_test=1.77057827 a_train=0.94445312 a_test=0.63780000
2018-05-12 03:59:51,589 - t=0.07070707 d=438.24093628 c_train=0.17236120 c_test=1.79997919 a_train=0.94511719 a_test=0.63640000
201
!ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi
!pip install gputil
!pip install psutil
!pip install humanize
import psutil
import humanize
import os
import GPUtil as GPU
2018-05-13 21:10:10,834 - t=0.0000 d=0.00 c_train=0.138679 c_test=1.676675 a_train=0.960391 a_test=0.635100 diff(a)=0.000000 eigs=[19.078777 -15.037691 -12.824933 8.370018 -8.173844 -7.9562387 7.3645334 -4.927397 -3.6613708 -1.5312731]
2018-05-13 21:13:36,278 - t=0.0526 d=336.53 c_train=0.188978 c_test=1.747933 a_train=0.942109 a_test=0.636900 diff(a)=0.001800 eigs=[6.568965 -5.835158 5.1431813 4.1658397 -2.9833426 2.9587455 1.3495047 -1.2531267 0.8539133 -0.06391297]
2018-05-13 21:17:47,884 - t=0.1053 d=616.08 c_train=0.150852 c_test=1.903739 a_train=0.953594 a_test=0.634100 diff(a)=-0.001000 eigs=[-6.1098914 -4.9726424 -4.364257 -4.1641197 3.4230855 -3.3937933 3.0466106 2.174941 -1.1291783 0.8382615]
2018-05-13 21:20:22,753 - t=0.1579 d=850.77 c_train=0.127392 c_test=2.050499 a_train=0.957969 a_test=0.633000 diff(a)=-0.002100 eigs=[8.076779 -7.205841 -5.549804 -4.353923 -3.440589 -3.1841156 2.5304813 2.5226054 -1.9029195 -0.107534155]
2018-05-13 21:29:40,405 - t=0.2105 d=1047.58 c_train=0.114826 c_test=2.16
2018-05-14 12:45:55,275 - t= +0.0000 d= +0.0000 c_train= +0.1425 c_test= +1.6767 a_train= +0.9600 a_test= +0.6351 diff(a)= +0.0000 time(eighsh)= +125.15 eigs=[ +1.5348 +5.0679 -6.0570 +7.4783 -10.9613 -12.9609 -14.8142 +15.2833 -15.6782 +19.5550]
2018-05-14 12:49:57,057 - t= +0.0526 d= +336.5288 c_train= +0.1837 c_test= +1.7479 a_train= +0.9394 a_test= +0.6369 diff(a)= +0.0018 time(eighsh)= +227.08 eigs=[ -0.0151 +0.1797 -0.5535 -0.9537 +1.9200 -2.3797 -4.3579 +5.5634 -6.2135 +6.4144]
2018-05-14 12:51:26,155 - t= +0.1053 d= +616.0807 c_train= +0.1502 c_test= +1.9037 a_train= +0.9518 a_test= +0.6341 diff(a)= -0.0010 time(eighsh)= +74.65 eigs=[ +1.0179 +5.3170 -5.8028 +6.4890 -10.6475 -13.4638 +14.7852 -16.7331 +17.7944 -19.7590]
2018-05-14 12:53:08,918 - t= +0.1579 d= +850.7733 c_train= +0.1273 c_test= +2.0505 a_train= +0.9590 a_test= +0.6330 diff(a)= -0.0021 time(eighsh)= +87.