duplicates = multiple editions
A Classical Introduction to Modern Number Theory,Kenneth IrelandMichael Rosen
A Classical Introduction to Modern Number Theory,Kenneth IrelandMichael Rosen
| # Time Series Testing | |
| import keras.callbacks | |
| from keras.models import Sequential | |
| from keras.layers.core import Dense, Activation, Dense, Dropout | |
| from keras.layers.recurrent import LSTM | |
| # Call back to capture losses | |
| class LossHistory(keras.callbacks.Callback): | |
| def on_train_begin(self, logs={}): | |
| self.losses = [] |
| """ | |
| Possibly correct implementation of an all conv neural network using a single residual module | |
| This code was written for instruction purposes and no attempt to get the best results were made. | |
| References: | |
| Deep Residual Learning for Image Recognition: http://arxiv.org/pdf/1512.03385v1.pdf | |
| STRIVING FOR SIMPLICITY, THE ALL CONVOLUTIONAL NET: http://arxiv.org/pdf/1412.6806v3.pdf | |
| A video walking through the code and main ideas: https://youtu.be/-N_zlfKo4Ec |
| import math | |
| import random | |
| def get_random_neighbour(state): | |
| neighbour = [house[:] for house in state] # Deep copy | |
| i = random.randint(0, 4) | |
| j = random.choice(range(0, i) + range(i+1, 4)) | |
| attr_idx = random.randint(0, 4) |
| package lib | |
| import fly.play.s3._ | |
| import java.io.OutputStream | |
| import scala.concurrent.Future | |
| import scala.concurrent.Await | |
| import scala.concurrent.duration.Duration | |
| import play.api.http.ContentTypeOf | |
| import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
| import play.api.libs.concurrent.Akka |
| package transactions | |
| import com.twitter.finagle.exp.mysql.{Client, OK, Result} | |
| class Db(mysqlClient: Client) { | |
| val insertOrder = "INSERT INTO orders (ref) VALUES(?)" | |
| val insertOrderItem = "INSERT INTO order_items (order_id, item_id) VALUES(?, ?)" | |
| def persistOrderWithItems[T](order: Order)(whenDone: (OK, Seq[Result]) => T): Future[T] = { |
| import java.net.{SocketOptions, Inet4Address, InetAddress, Socket} | |
| import java.util.concurrent.TimeoutException | |
| import akka.actor.{ActorRef, Props, ActorSystem} | |
| import akka.http.scaladsl.Http | |
| import akka.http.scaladsl.model.HttpMethods._ | |
| import akka.http.scaladsl.model._ | |
| import akka.http.scaladsl.model.ws._ | |
| import akka.io.Inet | |
| import akka.routing.BroadcastGroup |
| class HttpClient { | |
| def get(uri: URI): Future[String] | |
| } | |
| // return Future of next URI to get | |
| def getUri(): Future[URI] | |
| // return's available HttpClient from a pool | |
| def getHttpClient(): Future[HttpClient] |
| #!/usr/bin/env scalas | |
| /*** | |
| scalaVersion := "2.11.7" | |
| libraryDependencies += "com.typesafe.play" %% "play-netty-server" % "2.4.1" | |
| */ | |
| import play.core.server._ | |
| import play.api.routing.sird._ | |
| import play.api.mvc._ |
| /** Find the minimum amount of smoke (second) and resulting color (first) | |
| by splitting the sequence at every possible position, | |
| given `lookup` contains the best mix for subsequence. */ | |
| def minSmokeMixtureSingle(s: Seq[Int], lookup: Map[Seq[Int],(Int,Int)]): (Int,Int) = | |
| if(s.size == 1) | |
| (s(0),0) | |
| else if(s.size == 2) | |
| mix(s(0),s(1)) | |
| else { | |
| val splits = (1 to (s.size - 1)).map(s.splitAt) |