f = open('workfile.b','r')
a = f.read() # or .readlines()
f.close()
f = open('workfile.b','w')
# import numpy and set the printed precision to something humans can read
import numpy as np
np.set_printoptions(precision=2, suppress=True)
# set some prefs for matplotlib
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams.update({'text.usetex': True})
fig_width_pt = 700. # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Log into AWS | |
2. Select N. California as location | |
3. Select AMI - cs224d_tensorflow - ami-16327176 | |
4. | |
OR go to EC2 > Instances > Start | |
ssh into machine | |
ssh -i cs224d_AWS.pem ubuntu@IP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create new repository (repo | |
git init | |
# check status of files | |
git status | |
# add file | |
git add <filename> | |
# commit files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start the saved VM | |
Open Docker Quickstart - docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow | |
or docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow bash | |
or docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow:0.12.1 bash | |
maybe install modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
bucket = 'blah' | |
f = 'fileblah' | |
# get file from s3, read it, convert to json | |
s3 = boto3.resource('s3') | |
content_object = s3.Object(bucket, f) | |
file_content = content_object.get()['Body'].read().decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trainpct = 0.7 | |
trainidx = int(np.round(len(df)*trainpct)) | |
train_df = df.iloc[0:trainidx,:] | |
valpct = 0.2 | |
validx = int(np.round(len(df)*(trainpct+valpct))) | |
val_df = df.iloc[trainidx:validx,:] | |
test_df = df.iloc[validx::,:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scale data between 0 and 1 | |
scaler = MinMaxScaler(feature_range=(0, 1)) | |
scaler.fit(train_df.values) | |
train_scaled = scaler.transform(train_df.values) | |
val_scaled = scaler.transform(val_df.values) | |
test_scaled = scaler.transform(test_df.values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open('./data/generated/1127_22.json') as f: | |
data = json.load(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
fname = 'eye_detection.avi' | |
vidcap = cv2.VideoCapture(fname) | |
success,image = vidcap.read() | |
count = 0 | |
while success: | |
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file | |
success,image = vidcap.read() | |
print('Read a new frame: ', success) | |
count += 1 |
OlderNewer