diff options
Diffstat (limited to 'src/python/experiments')
-rwxr-xr-x | src/python/experiments/nn.py | 60 | ||||
-rw-r--r-- | src/python/experiments/view.py | 48 |
2 files changed, 108 insertions, 0 deletions
diff --git a/src/python/experiments/nn.py b/src/python/experiments/nn.py new file mode 100755 index 0000000..b36b103 --- /dev/null +++ b/src/python/experiments/nn.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# Import numpy for using matrix operations +import numpy as np + +# define an actovation function +def sigmoid(x,deriv=False): + if(deriv==True): + return x*(1-x) + return 1/(1+np.exp(-x)) + +# 0 0 1 0 +# 0 1 1 0 +# 1 0 1 1 +# 1 1 1 1 + +# define an input matrix +X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1] ]) + +# define an output matrix +y = np.array([[0,0,1,1]]).T + +# seed numpy +np.random.seed(1) + +# generate some weights +syn0 = 2*np.random.random((3,4)) - 1 + +# define how often the calculations should be run + +n = 100000 + +# loop +for i in range(n): + # define the first layer + l0 = X + + # define the second layer using the first layer and the weights + l1 = sigmoid(np.dot(l0,syn0)) + + # calculate an error + l1_error = y - l1 + + # calculate how fatal the error is + l1_delta = l1_error * sigmoid(l1,True) + + # adjust the weights + syn0 += np.dot(l0.T,l1_delta) + + # print some information + if (i % (n / 10000) == 0): + print("l1: " + str(l1)) + +print("") +print("Output After Training:") +print(l1) + +l0 = np.array([0, 1, 0]) +l1 = sigmoid(np.dot(l0, syn0)) +print(l1) diff --git a/src/python/experiments/view.py b/src/python/experiments/view.py new file mode 100644 index 0000000..a30ec48 --- /dev/null +++ b/src/python/experiments/view.py @@ -0,0 +1,48 @@ +import bpy +from numpy import genfromtxt +import os +import sys + +directory = "stars/" +# # print(directory) +# +files = [sys.argv[3]] + +# print("### \n\n") +# +# for data_file in os.listdir(directory): +# files.append(data_file) +# print(data_file) +# +# print("### \n\n") + +for data in files: + path = str(directory) + str(data) + print(path) + + verts = genfromtxt(path, delimiter=', ', skip_header=0) + + print(verts) + +# verts = [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0)] + + # create mesh and object + mesh = bpy.data.meshes.new(data) + object = bpy.data.objects.new(data,mesh) + + # set mesh location + object.location = bpy.context.scene.cursor_location + bpy.context.scene.objects.link(object) + + # create mesh from python data + mesh.from_pydata(verts,[],[]) + mesh.update(calc_edges=True) + + bpy.ops.object.select_all(action='SELECT') + +for area in bpy.context.screen.areas: + if area.type == 'VIEW_3D': + for region in area.regions: + if region.type == 'WINDOW': + override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} +bpy.ops.view3d.view_all(override) |