Posts

Featured post

ruby - Train neural network with sine function -

i want train neural network sine() function. currently use code , ( cerebrum gem): require 'cerebrum' input = array.new 300.times |i| inputh = hash.new inputh[:input]=[i] sinus = math::sin(i) inputh[:output] = [sinus] input.push(inputh) end network = cerebrum.new network.train(input, { error_threshold: 0.00005, iterations: 40000, log: true, log_period: 1000, learning_rate: 0.3 }) res = array.new 300.times |i| result = network.run([i]) res.push(result[0]) end puts "#{res}" but not work, if run trained network weird output values (instead of getting part of sine curve). so, doing wrong? cerebrum basic , slow nn implementation. there better options in ruby, such ruby-fann gem. most problem network simple. have not specified hidden layers - looks code assigns default hidden layer 3 neurons in case. try like: network = cerebrum.new({ learning_rate: 0.01, momentum: 0.9, hidden_l

Using django-mptt to get only the categories that have items -

sample structure: all uppercase: category mixed case: item root ├── books │   ├── fiction │   │   └── classics │   └── non-fiction ├── clothing └── electronics ├── laptops ├── phones │   ├── apple │   │   ├── iphone 6 │   │   ├── iphone 6 plus │   │   ├── iphone 6s │   │   └── iphone 6s plus │   ├── motorola │   │   ├── moto g4 │   │   ├── moto g4 play │   │   ├── moto g4 plus │   │   └── moto x │   └── samsung └── tablets └── apple i'm trying have index page show "electronics" category. "clothing" category shouldn't show since it's empty , "books" category shouldn't show either since, although has child categories, child categories don't have items. similarly, "electronics" page should show "phones" category. "laptops" category shouldn't show since it's empty , "tablets" category shouldn't show either since

android - Error generating Gradle in Eclipse ADT -

i have android project built in eclipse, , wish migrate android studio. though android studio works fine without gradle build files, want create them using eclipse adt explained here . however, when trying generate gradle files, eclipse shows me error log click on "finish". have tried decode means no avail. here error in question: java.lang.reflect.invocationtargetexception @ org.eclipse.jface.operation.modalcontext.runincurrentthread(modalcontext.java:477) @ org.eclipse.jface.operation.modalcontext.run(modalcontext.java:372) @ org.eclipse.jface.wizard.wizarddialog.run(wizarddialog.java:1028) @ com.android.ide.eclipse.adt.internal.wizards.exportgradle.gradleexportpage.generatebuildfiles(gradleexportpage.java:293) @ com.android.ide.eclipse.adt.internal.wizards.exportgradle.gradleexportwizard.performfinish(gradleexportwizard.java:32) @ org.eclipse.jface.wizard.wizarddialog.finishpressed(wizarddialog.java:827) @ org.eclipse.jface.wizard.wizarddialog.buttonpressed(wizar

Python TypeError: 'type' object does not support item assignment -

i have design , implement twosum class. should support following operations: add - add number internal data structure. find - find if there exists pair of numbers sum equal value. here code: class twosum(object): dict = {} def add(self,n): dict[n] = n #typeerror: 'type' object not support item assignment def find(self,n): in range(0,len(dict)+1): if dict[i] == none: continue val = n - dict[i] if dict[val] != none , val != i+1: return true return false test = twosum() test.add(1) test.add(3) test.add(5) print(test.find(4)) # true print(test.find(7)) # false i got error message typeerror: 'type' object not support item assignment "dict[n] = n" any or suggestion? thank much! lot of issues here, i'll try go through them 1 one the data structure dict = {} not overwriting python's dict , (see mgilson's co

javascript - Java with RWeka packege -

i have mac el capitan, 10.11.5, used rweka package, downloaded correctly , initialized error, when apply j48(species ~ ., data = iris) i have error error in .jnew("weka/core/attribute", attname[i], .jcast(levels, "java/util/list")) : java.lang.unsupportedclassversionerror: weka/core/attribute : unsupported major.minor version 51.0 i used java version these details, 52f85:~ kameljabreen$ java -version java version "1.7.0_79" java(tm) se runtime environment (build 1.7.0_79-b15) java hotspot(tm) 64-bit server vm (build 24.79-b02, mixed mode) please me solve problems, problm since 1 month, read lot problem in web sites. did thing, installing java jdk version 1.8 .... ect. used java 1.7. please give me solutions. in advance the rweka package depends on rjava package r-to-java communication, includes , uses own java 1.6 runtime. make things worse, behavior of rjava package platform dependent - uses "built-in" java on p

Android recyclerview adding duplicate elements on each activity creation -

when launch new fragment navigation drawer, it's meant take me home page cardview of matching profiles. works great first time , every profile want show there. however, when navigate away fragment , click on again, elements duplicated, , each subsequent time refresh page items duplicated once more. believe problem lies somewhere in recyclerview adapter not clearing on activity create, have't been able pinpoint it. here's fragment class public class homefragment extends fragment { private customlistadapter listadapter; private static final string profileurl = "http://10.0.2.2:3000/apip/buyers/profiles"; private static final string tag = selectbuyerprofile.class.getsimplename(); private progressdialog pdialog; private listview listview; private list<buyerprofile> buyersprofiles = new arraylist<buyerprofile>(); private view root; //private rvadapter recycleradapter; @override public view oncreateview(layoutin

reporting services - SSRS RowNumber counting a Groups in the report sequentially -

here need achieve. import purchasing system. created ssrs report works fine. im missing 1 more step finish it. i'll try explain achieved , remains achieved. achieved: lineid   lnarr2  1      751  1      793  1      804  2      804  3      804  4      804  1      807  2      807  3      807 the avobe 4 payments. payment id represented by: "lnarr2" (751, 793, 804 , 807). "lineid" counts number of lines pertaining group (purchase) in ssrs achieved by creating group, name: "lnarr2_grp" , group on: "lnarr2" expression "lineid" =rownumber("lnarr2_grp") remains achieved following on example above. need add document id (docid) . similar lineid represented follows: docid   lineid   lnarr2  1     1      751  2     1      793  3     1      804  3     2      804  3     3