juan_gandhi: (Default)
Вычисляю, скажем, норму вектора; а там такой TraversableOnce, и он такой, перед тем как начать суммировать, проверяет, уж не пустая ли коллекция; а народная проверка на пустоту, как это принято на джавных языках, состоит в том, чтобы посчитать длину и удостовериться, что оная больше нуля. Ну казалось бы, нахер тебе длина. Ну и т.д. 

Да даже если просто hasNext() чекать, и то, инстанциируется итератор, а для этого нужно фильтровать базар, например, ну и т.д.

Это я вбрасываю реализма. Написал, например, Foldable на джаве, чтобы "ускорить процесс". В три раза, например, на длинных векторах.

Короче, сильные типы важны, но под покровом типов надо как-то хотя бы от боксинга избавиться.
juan_gandhi: (Default)
...for running linear algebra stuff on gpu?

github.com/deeplearning4j/nd4j - for Java
github.com/deeplearning4j/nd4s - for Scala

Judging by the title, got a feeling that yes.
juan_gandhi: (Default)
  public static <T> T headOrNull(Iterable<T> ts) {
    Iterator<T> it = ts.iterator();
    return it.hasNext() ? it.next() : null;
juan_gandhi: (Default)
12:04:09 java.lang.NullPointerException
12:04:09 	at java.io.File.(File.java:277)
12:04:09 	at com.google.jenkins.flakyTestHandler.junit.FlakyTestResult.(FlakyTestResult.java:120)
12:04:09 	at com.google.jenkins.flakyTestHandler.plugin.FlakyTestResultCollector.call(FlakyTestResultCollector.java:15)
12:04:09 	at com.google.jenkins.flakyTestHandler.plugin.FlakyTestResultCollector.call(FlakyTestResultCollector.java:7)
12:04:09 	at hudson.remoting.UserRequest.perform(UserRequest.java:152)
12:04:09 	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
12:04:09 	at hudson.remoting.Request$2.run(Request.java:332)
12:04:09 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
12:04:09 	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
12:04:09 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
12:04:09 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
12:04:09 	at java.lang.Thread.run(Thread.java:745)
12:04:09 	at ......remote call to mr-0xc7(Native Method)
12:04:09 	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
12:04:09 	at hudson.remoting.UserResponse.retrieve(UserRequest.java:252)
12:04:09 	at hudson.remoting.Channel.call(Channel.java:781)
12:04:09 	at com.google.jenkins.flakyTestHandler.plugin.JUnitFlakyTestDataPublisher.getTestData(JUnitFlakyTestDataPublisher.java:49)
12:04:09 	at hudson.tasks.junit.TestDataPublisher.contributeTestData(TestDataPublisher.java:75)
12:04:09 	at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:183)
12:04:09 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
12:04:09 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
12:04:09 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
12:04:09 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
12:04:09 	at hudson.model.Build$BuildExecution.post2(Build.java:185)
12:04:09 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
12:04:09 	at hudson.model.Run.execute(Run.java:1763)
12:04:09 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
12:04:09 	at hudson.model.ResourceController.execute(ResourceController.java:98)
12:04:09 	at hudson.model.Executor.run(Executor.java:410)
12:04:09 Build step 'Publish JUnit test result report' marked build as failure
12:04:09 [BFA] Scanning build for known causes...
12:04:09 [BFA] No failure causes found
12:04:09 [BFA] Done. 0s

java const

Mar. 13th, 2017 02:21 pm
juan_gandhi: (Default)
"const is a reserved but unused keyword in Java.
juan_gandhi: (Default)
scala> object X { object Y { object Z }}
defined module X
scala> X.Y.Z.getClass()
res0: Class[_ <: x.y.z.type]="class" x$y$z$="X$Y$Z$" scala="scala"> X.Y.Z.getClass().getCanonicalName()
java.lang.InternalError: Malformed class name
	at java.lang.Class.getSimpleName(Class.java:1330)
	at java.lang.Class.getCanonicalName(Class.java:1399)
	at java.lang.Class.getCanonicalName(Class.java:1396)
	at java.lang.Class.getCanonicalName(Class.java:1396) 
P.S. Talked to Scala people. They know. They say Oracle promised to fix it in Java 9. Maybe.
juan_gandhi: (Default)
      if (entityInfo.containsKey(ApplicationMetricsConstants.TYPE_ENTITY_INFO)) {
        type =
      if (entityInfo.containsKey(ApplicationMetricsConstants.TYPE_ENTITY_INFO)) {
        type =

Were they drunk, or something.
juan_gandhi: (Default)
чтобы Ярн "пофиксить".
Нашел там JBoss. О бля. Старый добрый аппсервер в новой шкуре. Все тот же J2EE v 7.42.
juan_gandhi: (Default)
So, there's a "flag" in "config" that tells whether some data should be exported or not:

Some responsible guy decided to test both cases, with export and without.
So, in the test case he adds:

      dl._export_weights_and_biases = RandomUtils.getRNG(fnametrain.hashCode()).nextBoolean();

The commit comment was “Test both true and files for export_weights_and_biases”

Now, wtf is fnametrain? It's the name of the file with test data.

We take the file name. Calculate its hash code. Seed it into an RNG. And then take the first bit generated.

I'm afraid a lot of "data science" is like this:
- Make our code so complicated that nobody can make any sense out of it.
- Profit.


Dec. 13th, 2016 05:39 pm
juan_gandhi: (VP)
scala> "x:".split(":")
res1: Array[String] = Array(x)

scala> ":y".split(":")
res2: Array[String] = Array("", y)

scala> ":".split(":")
res3: Array[String] = Array()

scala> "".split(":")
res4: Array[String] = Array("")

juan_gandhi: (VP)
    for (int i = 0; i < weightColumns.size(); i++) {
      this.weights[i] = new DlColumn<>("fv" + i, weightColumns.get(i));

(consider it a tentative interview question)
juan_gandhi: (VP)

"Why is subtracting these two times (in 1927) giving a strange result?"

public static void main(String[] args) throws ParseException {
    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
    String str3 = "1927-12-31 23:54:07";  
    String str4 = "1927-12-31 23:54:08";  
    Date sDt3 = sf.parse(str3);  
    Date sDt4 = sf.parse(str4);  
    long ld3 = sDt3.getTime() /1000;  
    long ld4 = sDt4.getTime() /1000;

The output is 353...


"at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. So "1927-12-31 23:54:08" actually happened twice, and it looks like Java is parsing it as the later possible instant for that local date/time - hence the difference."
juan_gandhi: (VP)
 * A marker interface for classes that have no data inside
 * Meaning, two instances are equal if they have the same class
public interface JustCode extends Serializable {
public interface Function<X, Y> extends JustCode {
  Y apply(X x);
public interface Function2<X, Y, Z> extends JustCode {
  Z apply(X x, Y y);
  public int hashCode(JustCode x) {
    return x == null ? 0 : x.getClass().hashCode();

  public boolean equal(JustCode x, JustCode y) {
    return x == null ? y == null : y != null && x.getClass() == y.getClass();

No shit, just discovered this kind of data.
You've probably noticed that I kind of prefer S to OOP. :)
juan_gandhi: (VP)
  @Test public void null_is_null() {
    Double Null = ((Double)null);
    boolean itis = Null instanceof Double;

Comments? I'm pretty much lost here.
juan_gandhi: (VP)
  @Test public void testFunctionOfTwoArgs() throws IOException {
      Vec sines   = fill(1 << 24, new Function<Long, Double>() {
        public Double apply(Long x) { return Math.sin(0.0001 * x); }
      Vec cosines = fill(1 << 24, new Function<Long, Double>() {
        public Double apply(Long x) { return Math.cos(0.0001 * x); }

      Function<Double[], Double> sq = new Function<Double[], Double>() {
        public Double apply(Double[] x) { return x[0]*x[0] + x[1]*x[1];}

      Vec iv = register(new FunVec(sq, sines, cosines));

      new MRTask() {
        @Override public void map(Chunk c) {
          for (int i = 0; i < c._len; ++i) {
            double x = c.atd(i);
            if (Math.abs(x - 1.0) > 0.0001) throw new RuntimeException("moo @" + c._cidx + "/" + i + " x=" + x + "; expected=1.0");

Questions? Suggestions? I know, performance kind of sucks, no arity-awareness, no specialization. But that's ok so far.
juan_gandhi: (VP)
Playing with Java. С местным Чабой тоже собачусь, осторожненько. Он (Клиф Клик), конечно, титан, но тупой, весь такой из 85-го года, си на восьмибитном процессоре - это то, на чем он учился программировать. Кругом у него байтовые массивы, и он думает, что круто. Лезет с хуйней.

Ok, whatever. I just remember how class serialization/deserialization was so much of a trouble. But now, wow, I have a class, turn it into bytes, pass to another node, where I convert it back to Function<X,Y> - and then I call it.

  public void testDeserializationAndEval() throws Exception {
    byte[] bytes = readHex(sampleCode);
    Class c = loadClass("water.util.SampleClosure", bytes);
    assertEquals("X=42", evalFunction(c, 42));

  String sampleCode = 
                  "ca fe ba be 00 00 00 33 00 2d 0a 00 0b 00 1d 07 \n" +
                  "00 1e 0a 00 02 00 1d 08 00 1f 0a 00 02 00 20 0a \n" +

(you probably recognize "cafebabe", right?)
juan_gandhi: (VP)
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

 * Written by Doug Lea with assistance from members of JCP JSR-166
 * Expert Group and released to the public domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
    implements ConcurrentMap<K,V>, Serializable

(Well, in general, a pretty good progress in Java 8...)
juan_gandhi: (VP)
Смотрю вот на этот кусок кода: new NewChunk[fr.numCols()]; и не понимаю, что это за зависимые типы тут у нас завелись.

И потом вдруг доходит.
juan_gandhi: (VP)
Don't you think that the existence of type Object in JVM-like languages makes them basically type-free? Since everything is a "subtype" of Object anyway. Equality sucks, substitution sucks, etc.
juan_gandhi: (VP)
The more I deal with Scala legislators, the more I agree that Scala is the new Java (and Java is the new Cobol, and Cobol is the new Latin, and Latin is the new petroglyph code).

A couple of weeks ago we went for a hike and saw a rather small dog, a male, that stood on its front paws and tried to pee on a trunk as high as possible.



juan_gandhi: (Default)

August 2017

   1 23 4 5
6 7 8 9 10 11 12
13 14 15 16 1718 19


RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 21st, 2017 02:50 am
Powered by Dreamwidth Studios