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
package main | |
import ( | |
"fmt" | |
"log" | |
"reflect" | |
"github.com/nlpodyssey/spago/ag" | |
"github.com/nlpodyssey/spago/gd" | |
"github.com/nlpodyssey/spago/gd/sgd" |
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
package mypool | |
// MyPool is a naive implementation of a pool, based on broadcast channel. | |
// You can use this pool in the same way you use sync.Pool. | |
type MyPool struct { | |
pool chan interface{} | |
// New optionally specifies a function to generate | |
// a value when Get would otherwise return nil. | |
New func() interface{} |
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
------------------------------------------------------------------------------ | |
-- -- | |
-- Copyright (C) 2011-2017 Matteo Grella <[email protected]> -- | |
-- -- | |
-- This work is licensed under a Creative Commons -- | |
-- Attribution-ShareAlike 4.0 International License. -- | |
-- -- | |
-- This file contains a subset of the Italian Grammar expressed as a set -- | |
-- of constraints, in line with WCDG formalism. The 243 constraints below -- | |
-- are used in my most recent dependency parsing experiments which combine -- |
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
kubectl get po --all-namespaces --field-selector 'status.phase==Failed' -o json | kubectl delete -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
// see http://www.netlib.org/clapack/cblas/dgemv.c | |
package main | |
/* | |
#cgo LDFLAGS: -L/usr/lib/libblas -lblas | |
#include <stdlib.h> | |
extern void dgemv_(char* trans, int *m, int *n, double *alpha, | |
double *A, int *lda, double *x, int *incx, double *beta, double *y, | |
int *incy); | |
*/ |
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
func reverse(lst []string) chan string { | |
ret := make(chan string) | |
go func() { | |
for i, _ := range lst { | |
ret <- lst[len(lst)-1-i] | |
} | |
close(ret) | |
}() | |
return ret | |
} |
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 com.kotlinnlp.simplednn.simplemath.ndarray.dense.DenseNDArray | |
fun List<DenseNDArray>.sumWithPrevAndNext(): List<DenseNDArray> = this.indices.map { i -> | |
val cur = this[i].copy() | |
if (i > 0) cur.assignSum(this[i - 1]) | |
if (i < this.lastIndex) cur.assignSum(this[i + 1]) | |
cur | |
} | |
fun List<DenseNDArray>.addBackwardOfSumWithPrevAndNext(gradients: List<DenseNDArray>) = this.indices.map { i -> |
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
/** | |
* Returns the combinations of the elements in this list as a list of pairs. | |
* | |
* The returned list is empty if this collection contains less than two elements. | |
* | |
* @return the combinations of the elements | |
*/ | |
fun <E>List<E>.combine(): List<Pair<E, E>> = this.foldIndexed(mutableListOf()) { i, acc, element -> | |
for (j in i + 1 until this.size) { |
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
/** | |
* @param resource the path to the resource to load | |
* | |
* @return the content of the resource | |
*/ | |
fun loadResource(resource: String): String = | |
try { | |
object {}.javaClass.getResource(resource).readText(Charsets.UTF_8) | |
} catch (all: Exception) { | |
throw RuntimeException("Failed to load resource=$resource!", all) |
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 com.rabbitmq.client.Connection | |
import com.rabbitmq.client.ConnectionFactory | |
/** | |
* Create a RabbitMQ Connection. | |
* | |
* @param host the host | |
* @param port the port | |
* @param username the username (can be null) | |
* @param password the username (can be null) |
NewerOlder