Posts

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 fo...

node.js - Meteor deploy on Heroku Error deploying Node -

Image
i built meteor app, , runs on local machine, have meteor installed. i have never deployed app online, , trying put app on heroku. i first tried use buildpack/jordansissel/heroku-buildpack-meteor.git, got error "meteor requires node v0.10.41 or later" i tried use buildpack/michaltakac/meteor-buildpack-horse.git failed push because couldn't unpack node. lastly i've tried kevinseguin/heroku-buildpack-meteor.git lots of warnings npm depricated http://prntscr.com/bewzak when @ logs says "slug compilation failed: failed compile node.js app" i error: mongo_url must set in environment i don't know enough understand errors are, or how app deployed image of errors: http://prntscr.com/bex0av my goal site on gr-fireworks.herokuapp.com i contacted heroku helpdesk , said couldn't me because issue outside scope of heroku support. i tried reach out snap ci said successful in deploying it, when try type in did, still getting error node http...

Powershell insert object into SQL Server database more elegant solution -

i have array of objects ( $itemobjectarray ), each 1 having these properties , values so: id : 1234 location : usa price : $500 color : blue i have sql server 2012 table called items column names match object property names so: table items ( id location price color primary key (id) ) i have created following code insert object sql server table. think code little crude. there more elegant way since column names match object property names? $itemobjectarray | %{ #step through array #get property names, match column names $names = $_ | get-member -membertype properties foreach($name in $names.name){ #make sql string column names $cols += $name + "," } $cols = $cols.trimend(",") #get rid of last comma foreach($name in $names.name){ #step through properties, values , build values string $vals += "'" + $_.$($name) + "'," } $vals ...

java - Getting a "money converter" Android app to convert one currency to another based on user input -

so here instructions: retrieve current currency conversion rates : http://api.fixer.io for example, convert dollars british pounds call: http://api.fixer.io/latest?base=usd&symbols=gbp 2- provide 2 spinners 5 currencies of choosing. 3 - use async calls conversion lookups, shouldn't block ui thread. now i've gotten far pulling values json api , getting display conversion rate of 1 usd 1 gbp (this done hard coding in usd , gbp pull json api. i'm struggling trying hard coded currencies instead pulled pair of spinners containing 5 different currencies. additionally i'm struggling rate multiply user specified amount (for example if rate 0.69 , user wants convert 10usd gbp app should report converted amount 6.90gbp) @ present getting "operator * cannot applied double" @ present app crashes @ launch , first priority getting run , convert 1 monetary unit equivalent amount of monetary unit. this fetchconversionratetask.java f...

c++ - In Lists, is remove same as erase? -

those 2 sample examples of trying say. first example. std::list<someclass*> somelist; // have defined someclass m method remove std::remove(somelist.begin(), somelist.end(), m); method erase auto = std::find(somelist.begin(), somelist.end(), m); if (it != somelist.end()) { somelist.erase(it); } question: there difference in behavior or performance? second example. well actual purpose of asking question, std::list<someclass*> somelist; someclass* m = nullptr; using same methods first example, behavior, using both methods. here standard says: erase: iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); invalidates iterators , references erased elements. remove: void remove(const t& value); template <class predicate> void remove_if(predicate pred); erases elements in list referred list iterator i for following conditions hold: *i == value, pred(*i) != false. in...

plsql - IT IS SHOWING THAT PROCEDURE CREATED WITH COMPILATION ERROR? -

/* procedure */ set serveroutput on; declare number; b number; sum number:=0; procedure addd(x in number,y in number,sum out number) begin sum:=x+y; end; begin a:=12; b:=54; addd(a,b,sum); dbms_output.put_line(sum); end; /

C++ Can't Figure Out How To Shuffle Image -

i've been stuck on bit now. need break image down 9 boxes(2d array) , shuffle it. imported image twice, once src , once target, 2 arrays. need src image shuffle , output target, without repeating tile, cant figure out how that....here's code: #include "pgmio.h" #include <iostream> #include <ctime> void shuffle_image_3(pgm src, pgm & target); int main(int argc, char ** argv) { srand(time(null)); pgm src, target; readpgm("random.pgm", src); //2d array src readpgm("random.pgm", target); //2d array target shuffle_image_3(src, target); writepgm("random_shuffled.pgm", target); system("random_shuffled.pgm"); return 0; } void shuffle_image_3(pgm src, pgm & target) { if (src.row != target.row || src.col != target.col) { return; } //if sizes aren't equal, returns nothing //"used[i][j]==true means tile in source //at row , column j has been co...

Returning (android.hardware.Camera) in landscape mode -

i building app contains video capture custom camera surface view. works fine in portrait mode, when change landscape mode camera preview goes blank screen. here's code i'm using: @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); setcontentview(r.layout.camera_activity); camera1 = camera.open(camid); try { camera1.setpreviewdisplay(surfaceholder); camera1.startpreview(); } catch (ioexception e) { e.printstacktrace(); } } in configurationchanged function i'm not getting camera1 object. how can solve this? you need override onsaveinstancestate(bundle savedinstancestate) , write application state values want change bundle parameter this: you can saved instance of each variable this @override public void onsaveinstancestate(bundle savedinstancestate) { super.onsaveinstancestate(savedinstancestate); // save ui ...

Trying to remove top row from excel spreadsheet using Python -

this first question here if don't follow perfect etiquette please forgive me. have been searching answer 6 hours figured time ask. i'm new python, , i'm trying automate data entry selenium. i'm doing well, stuck @ part pull data excel. data pulling isn't problem, telling excel delete top row, or move onto next, is. here sample of script: import pandas pd pandas import excelwriter import numpy np xl = pd.excelfile('c:\\users\\steph_000\\desktop\\students2.xlsx') xl wr = pd.excelwriter('c:\\users\\steph_000\\desktop\\students2.xlsx') xl.sheet_names ['sheet1'] df = xl.parse('sheet1') #this reads sheet dataframe df cp = pd.read_excel('c:\\users\\steph_000\\desktop\\students2.xlsx') idnum = cp[:1] #this pulls first row variable print(idnum) #this prints search bar student chart = cp[1:] #this pulls first row variable print(chart) df.to_excel(wr, 'sheet1') wr.save() #this supposed overwrite it, saves bla...

go - String pointers -

consider following program ( http://play.golang.org/p/ibastvudte ): package main import ( "fmt" ) func changestringvaluenotok(dest *string, src string) { dest = &src } func changestringvalueok(dest *string, src string) { *dest = src } func main() { := "hello" b := "world" changestringvaluenotok(&a, b) fmt.println(a) // still "hello" changestringvalueok(&a, b) fmt.println(a) // "world" } my goal call function , change value of string. works fine second function, not first. question: meaning of *dest = src compared dest = &src ? guess former "the contents of dest src" , latter "change dest variable points address of src" discards previous value, not contents of a. if right, don't understand how *dest = src works. i hope question isn't fuzzy. *dest = src is: set value pointed @ dest value in src . it's effective. dest = ...

Google Apps Engine: Using later version of NumPy -

i'm trying use pandas module through google apps engine. requires numpy 1.7 or later. unfortunately google apps engine stuck @ 1.6.1. i've loaded several other third party modules in libs folder, including plotly (for using pandas) without problem, placing later version of numpy in libs folder isn't working. so, know way use newer version of numpy apps engine? it looks libs folder supports pure python packages don't have c-extensions: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library numpy has sorts of c-extensions, looks may stuck older version of numpy google app engine supports. pandas doesn't supported library , has c-extensions, seems can't use either. i've read, have use google app engine flexible environment install class of packages.

running embedded R in C -

i have written piece of c code declares square matrix of size 4x4. samples sampling function called rgig in package generalizedhyperbolic in r. inverses matrix using gsl library gnu , spits out result. exercise in calling r c. #include <stdio.h> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <stddef.h> // gsl #include <gsl/gsl_machine.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_cdf.h> #include <gsl/gsl_cblas.h> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> #include <gsl/gsl_linalg.h> // r embedding in c #include <rinternals.h> #include <rdefines.h> #include <rembedded.h> #include <r_ext/parse.h> void gsl_square_matrix_inverse (gsl_matrix *, gsl_matrix *, int); sexp get_rinvgauss(void); int main(void) { // define dimension n of matrix // , s...

Java: Print first, fourth, seventh... of an array using only ONE LOOP? -

given array of integer. i want first print print 1st, 4th, 7th.. numbers. 2nd, 5th, 8th.. , 3rd, 6th, 9th.. i want use 1 loop iterate through array. how can this? (note: size of array 4, 7, 10, 13.. , on, i.e. in increments of 3.) thanks. write function private int index(int i, int length) which computes right index loop variable i edit wasn't easy first thought: public static void main(string[] args) { int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; (int = 0; < array.length; i++) { system.out.println(array[index(i, array.length)]); } } private static int index(int i, int length) { int third = (length + 2) / 3; if (length % 3 == 1 && >= third) { // spezial, because second third smaller return index(i - 1, length - 1); } int group = % third; return (group) * 3 + (i / third); } edit did cleanup;

javascript - pass value to iframe on popover using jquery -

i have written code show popover iframe on hover link. want pass link value iframe window on popover. how can that? here code <a href="#" class="show-pop-iframe btn btn-default " data-placement="vertical" id="sample" value="email@domain.com">email@domain.com </a> <a href="#" class="show-pop-iframe btn btn-default " data-placement="vertical" id="sample1" value="email1@domain1.com">email1@domain1.com </a> <div id="auto"></div> (function(){ var settings = { trigger:'hover', title:'send mail user', content:'<p>this webui popover demo.</p><p>just enjoy , have fun !</p>', width:auto, multi:true, closeable:false, style:'', delay:300, padding:true, ...