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
// Paste this in Playground | |
infix operator ∘ | |
prefix operator ∑^ | |
typealias ItoD = (Int) -> Double | |
func *(lhs: Int, rhs: Double) -> Double { | |
return Double(lhs)*rhs | |
} |
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
// Paste this in Playground | |
import CoreData | |
let url = Bundle.main.url(forResource: "HikingApp", withExtension: "momd") | |
let model = NSManagedObjectModel(contentsOf: url!) | |
let container = NSPersistentContainer(name: "HikingApp") |
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
let docsDir = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first! | |
print(docsDir) | |
let archiveURL = docsDir.appendingPathComponent("landmark") | |
print(archiveURL.path) | |
class LandmarkClass : NSObject, NSCoding { | |
var name = "" | |
init(name: String) { | |
self.name = name |
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
extension Double { | |
var km: Double { return self } // This is stored as km, everything else will need conversion instead. | |
var mile: Double { return 0.6214 * self } | |
} | |
10.km | |
10.mile | |
let x = 10.0 // if user unit is miles | |
let dist = x/1.mile |
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
a = tf.constant(2) | |
b = tf.constant(3) | |
x = tf.add(a, b) | |
writer = tf.summary.FileWriter('./graphs', tf.get_default_graph()) | |
with tf.Session() as sess: | |
print(sess.run(x)) | |
writer.close() |
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 numpy as np | |
# original image is 224x224x3 of dtype uint8 | |
renorm_image = np.reshape(original_image, (original_image.shape[0]*original_image.shape[1],3)) | |
renorm_image = renorm_image.astype('float32') | |
renorm_image -= np.mean(renorm_image, axis=0) | |
renorm_image /= np.std(renorm_image, axis=0) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.