• Breaking News

    Saturday, June 9, 2018

    Critical conditions, Race Condition, Mutex, Semaphore Ask Programming

    Critical conditions, Race Condition, Mutex, Semaphore Ask Programming


    Critical conditions, Race Condition, Mutex, Semaphore

    Posted: 09 Jun 2018 04:36 PM PDT

    [Tensorflowjs] Neural networks

    Posted: 09 Jun 2018 07:06 PM PDT

    Hello guys!

    I am a Junior Computer Science major looking to expand my resume. One of the things I decided I wanted to learn more about was neural networks and AI in general. Which is where this question comes from. I am building a neural net to predict the location of the position of the mouse cursor. My thoughts were that I would use the current mouse position to train the net and it would output a prediction x,y coordinate to draw the circle. My problem is that, the neural net is working, in that it generates x,y values just not the correct ones. I am using tensorflowjs and p5js to draw elements to the browser. I drew my inspiration from this article for those interested. https://franpapers.com/en/machine-learning-ai-en/2017-neural-network-implementation-in-javascript-by-an-example. Any help would be appreciated!

    let LR = 0.5; let training_xs; let training_ys; let predictionX = null; let predictionY = null; let first; let second; let EPOCHS = 100; const model = tf.sequential(); function setup() { canvas = createCanvas(400, 400); buildNeuralNet(); first = random(0,1); second = random(0,1); } function draw() { background(0); fill(255); ellipse(mouseX,mouseY,5,5); if(frameCount % 35 == 0) train(); if(predictionX != null && predictionY != null){ var mappedPredictionX = map(predictionX,0,1,0,400); var mappedPredictionY = map(predictionY,0,1,0,400); noFill(); stroke(255); strokeWeight(2); ellipse(mappedPredictionX,mappedPredictionY,20,20); } } function buildNeuralNet() { // Neural network with 2 inputs x,y and 2 outputs the x,y of the circle const hidden = tf.layers.dense({ units:2, inputShape:[2], activation:'softmax' }); const outputs = tf.layers.dense({ units:2, inputShape:[2], activation:'softmax' }); model.add(hidden); model.add(outputs); const optimizerSGD = tf.train.sgd(LR); model.compile({ optimizer:optimizerSGD, loss:tf.losses.meanSquaredError }); } async function train(){ //console.log("Training..."); // train the neural network with the mouse x and y position const tensor_xs = tf.tensor2d([[first,second]]); const tensor_ys = tf.tensor2d([[first,second]]); const history = await model.fit(tensor_xs,tensor_ys,{ epochs:20, shuffle:true }); console.log(history.history.loss[0]); tensor_xs.dispose(); tensor_ys.dispose(); return history; } function mousePressed(){ // make a prediction based on the current mouse x and y location normalized to a value in => [0,1] console.log("Training complete!"); let mappedX = map(mouseX,0,400,0,1); let mappedY = map(mouseY,0,400,0,1); const prediction = tf.tensor2d([[mappedX,mappedY]]); const output = model.predict(prediction); predictionX = output.dataSync()[0]; predictionY = output.dataSync()[1]; // compare prediction values against actual values console.log(mappedX,mappedY); console.log(predictionX,predictionY); prediction.dispose(); output.dispose(); } 
    submitted by /u/theWearyProgrammer
    [link] [comments]

    Null Pointer Exception Array in Processing

    Posted: 09 Jun 2018 11:18 AM PDT

    import processing.serial.*; Serial port; String inputString; String []data; void setup(){ size(600,400); background(100,200,400); port = new Serial(this, Serial.list()[1], 9600); port.bufferUntil('\n'); } void draw(){ int X_Position = int(data[0])/2; int Y_Position = int(data[1])/2; fill(100); rect(X_Position, Y_Position, 10, 10); } void serialEvent (Serial port){ String inputString = port.readStringUntil('\n'); if(inputString != null) inputString = trim(inputString); //cut off all white space data = split(inputString, ","); } 

    Whenever I try to run this code a Null pointer exception comes up in my screen for the String array []data. How would would I initialize the array such that I wouldn't have this come up?

    submitted by /u/AManlikeStephen
    [link] [comments]

    What can I learn in advance for my computer science degree?

    Posted: 09 Jun 2018 08:58 PM PDT

    Hello, I am a 16-year-old student about to undertake my BSCS degree later this June. I am well versed in web development, and have decided to take the shift to more CS related skills. I am very excited to learn, so I am asking for advice on what topics I should learn in advance so I'm more prepared once classes begin. I have already begun relearning Python (It was my first language that I forgot) and some precalculus. Any advice and/or resources would be appreciated. Thanks! :)

    submitted by /u/PrivateZer0
    [link] [comments]

    Python ctypes: how to pass row outputs from a C function into a pandas DataFrame?

    Posted: 09 Jun 2018 08:24 PM PDT

    My question is how to parse tab-delimited output from a C function into a pandas DataFrame via ctypes:

    I am writing a Python wrapper in Python3.x around a C library using ctypes. The C library currently does database queries. The C function I am accessing return_query() returns tab-delimited rows from a query, given the path to a file, an index, and a query-string:

    int return_query(structname **output, const char *input_file, const char *index, const char *query_string); 

    As you can see, I'm using output as the location to store all records from the query, whereby the structname is a struct for the rows

    I also have a function which prints to STDOUT:

    int print_query(const char *input_file, const char *index, const char *query_string); 

    My goal is to access these functions via ctypes, and pass the tab-delimited row outputs into a pandas DataFrame.

    My problem is this:

    (1) I could try to parse the STDOUT of print_query(); however, these queries could result in large tab-delimited DataFrames. I worry this solution isn't efficient, as it might not scale to +10000s of rows. Other questions have roughly covered how to catch STDOUT from C functions in Python via ctypes:

    https://stackoverflow.com/questions/9488560/capturing-print-output-from-shared-library-called-from-python-with-ctypes-module

    (2) Could I access output somehow, and pass this to a pandas DataFrame? I'm currently not sure how this would work, e.g.

    import ctypes lib = CDLL("../libshared.so") ### reference to shared library, *.so lib.return_query.restype = ctypes.c_char lib.return_query.argtypes = (???, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p) 

    What should the first argument be, and how would I pass it into something which could be a pandas DataFrame?

    (3) Perhaps it would be better to re-write the C functions which return tab-delimited rows into something more accessible via ctypes?

    submitted by /u/Zeekawla99ii
    [link] [comments]

    Date of Birth field acting weird

    Posted: 09 Jun 2018 02:37 PM PDT

    Hi, Im creating a Dob field suing typescript and my logic for the field is basically like this:

    parseDob(): void {

    if(this.dob.value.length == 2) {
    this.dob.setValue(this.dob.value + "/");
    }
    if(this.dob.value.length == 5 ) {
    this.dob.setValue(this.dob.value + "/");

    }

    }

    It works but when when the user tries to delete something if they made a mistake the / make it hard to delete. Its basically really buggy. Any tips on how to solve it? I was thinking using an event listener and see if backspace was entered and then do something but i'm having trouble implementing it. Any help is appreciated

    submitted by /u/Michaelw000
    [link] [comments]

    how to make money off of free game without making it p2w?

    Posted: 09 Jun 2018 12:01 PM PDT

    im having trouble thinking of ways to make money off my free game without making it p2w i know there are cosmetics but what else could i use to make money?

    submitted by /u/Mobile_Couch
    [link] [comments]

    What's the best way? Preferably Access+VB

    Posted: 09 Jun 2018 01:41 PM PDT

    Sorry if incorrect flair.

    I want something simple: a form where I check boxes or input data and it populates a standard text comment for input into our standard production system.

    Reps take actions and comment notes into the blank comment field and because it's not an option to create a more comprehensive comment function in the actual system (that would've been ideal). I need to build a module that generates a standard comment from a variety of choices because I've learned how to query the system for standardized text in the comment tables.

    So if a user checks a box for "call" the field for entering a phone number becomes editable, etc and at the bottom, depending on the options and info entered, a standard comment is available to copy and paste into the other system.

    If anyone that knows much more than me can set me down the best path for this project, that would be most helpful. On my team, I have access to the knowledge and skills for more basic routes but ideally I'd like to build something I could then make available for use to a large group of people with very limited computer ability.

    Thank you in advance!

    submitted by /u/Karmallarma
    [link] [comments]

    Another way to write this statement in C?

    Posted: 09 Jun 2018 12:43 PM PDT

    assuming that I am using this bitwise operator to shift the bits stored in 'im' 16 times to the left, is there any other form I can write: im = im << 16;

    Weird question, I know, but is there any other way I can write this and get the same result?

    submitted by /u/friendsblow
    [link] [comments]

    Program to interpret data such as pitch roll yaw over time

    Posted: 09 Jun 2018 09:55 AM PDT

    I have a lot of data of pitch roll and yaw data in degrees over time (I can also have it in radians). I am wondering if there is some sort of framework that already exists to create a graphical representation of a rocket at a certain point in time with all of my flying data.

    Thanks!

    submitted by /u/rocketphone
    [link] [comments]

    This time it's not even I'm bad at python, I'm just bad at math

    Posted: 09 Jun 2018 11:24 AM PDT

    from math import *

    from turtle import *

    a = 120

    b = 90

    c = 170

    a_equation = ((b)**2 + (c)**2 - (a)**2) / (2 * (b) * (c))

    a_rounded = round(a_equation , 4)

    a_inverted = acos(a_rounded)

    a_degrees = a_inverted * 100

    print(a_degrees)

    b_equation = ((a)**2 + (c)**2 - (a)**2) / (2 * (a) * (c))

    b_rounded = round(b_equation , 4)

    b_inverted = acos(b_rounded)

    b_degrees = b_inverted * 100

    print(b_degrees)

    c_degrees = (180 - (b_degrees + a_degrees))

    print(c_degrees)

    fd(a)

    lt(180 - b_degrees)

    fd(c)

    lt(180 - a_degrees)

    fd(b)

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    this is supposed to make a triangle but all i get is something that isn't a triangle

    submitted by /u/_danimite
    [link] [comments]

    Splitting the application into the smaller ones like in Adobe Flash/Air

    Posted: 09 Jun 2018 08:30 AM PDT

    Adobe Flash/Air allows splitting application into smaller pieces in the form of SWF files. Later additional SWFs can be downloaded and loaded into the main application as documented here: https://helpx.adobe.com/flash/kb/load-external-swf-swf.html I searched if there is the same or similar concept in other languages/technologies but with no success.

    While this idea doesn't seem any good from the security point of view, I would like to ask. Do you know any example of such concept in different from Flash and ActionScript languages or technologies?

    submitted by /u/sorochanalex
    [link] [comments]

    Is it worth to spend time on learning Dart and Flutter or should i choose native languages to develop apps?

    Posted: 09 Jun 2018 05:50 AM PDT

    Video Site

    Posted: 09 Jun 2018 04:22 AM PDT

    Noob Question: What is the ideal framework, stack, language, algorithm or method to build a video site. Something like a self hosted YouTube or Vimeo clone with minimal features.

    Should I learn how to build a cms first or is there a simpler and elegant way to implement this without reinventing the wheel.

    submitted by /u/Pls_I_Need
    [link] [comments]

    How to code a series of random lines within a certain perimeter

    Posted: 09 Jun 2018 04:43 AM PDT

    Hi!

    Aspiring programmer here. I've been given the task to find Pi by the ratio of the amount of random lines that fall on either a circle or a square, that are semi-aligned to each other.

    Luckily I'm at least able to code a circle, a line etc. Or bunch of random numbers between x - y. What I simply can't figure out yet is how to write a code that draws a series of random lines(coloured green if they fall on the circle, red if they fall on the square surrounding it).

    This might be super basic stuff but I just can't figure it out. Any help/advice would be greatly appreciated!

    submitted by /u/Raffi_Besik
    [link] [comments]

    Help making an overflowed div scroll to the bottom as list elements are appended to it

    Posted: 08 Jun 2018 11:42 PM PDT

    https://luandavidn.github.io/beep_boop/

    I'm not so good with computer words. The page's technically for a coding assignment, but that stuff's done and aside. Now I'm just super curious about why my page is bugging out while I try to spruce it up.

    I'm a beginner and don't know jack. Atm, I'm realising the importance of branches, because at one point I had the site going so when a user would input a number, the lists on both sides would append all the way to the bottom (300 items capped), smooth(ish) scrolling the whole way through.

    For some reason it's just stopping at seemingly the div's height now? And I have no idea where to even begin debugging, between confusion about if it's CDN's acting up, or if all my animations and horrible Javascript/jQuery/anything have killed everything.

    Also I'm so sorry if this isn't a proper way/place to ask these sort of questionsdfg. I'm not savvy, and I'm scared of stackoverflow kicking my ass, oh no.

    Edit: It works fine when I use it through Chrome's inspect and device view toolbar for some reason, like the previews for screen sizes. Why is this happening.

    Edit: The page works fine on Firefox and Opera. Is this a Chrome thing. Is accounting for how pages work on different browsers actually a thing. Oh god.

    submitted by /u/kotaimlost
    [link] [comments]

    No comments:

    Post a Comment