jonpappalord / ditras Goto Github PK
View Code? Open in Web Editor NEWDITRAS (DIary-based TRAjectory Simulator), a mathematical model to simulate human mobility
License: Apache License 2.0
DITRAS (DIary-based TRAjectory Simulator), a mathematical model to simulate human mobility
License: Apache License 2.0
I did clone of the project. When I execute the "python DITRAS.py 10000 720 location2info_trentino od_matrix.pkl diary_generator_1hour.pkl trajs_10000_720.csv
" command, I receive the error message:
ValueError: could not convert string to float
Traceback Full:
Traceback (most recent call last):
File "DITRAS.py", line 467, in <module>
class DITRAS(object):
File "DITRAS.py", line 474, in DITRAS
def __init__(self, n_agents=10000, length=168, diary_generator=MD(),
File "DITRAS.py", line 396, in __init__
self.markov_model = pickle.load(open(filename, 'rb'))
ValueError: could not convert string to float
OS: Windows 10
Python 3.7.5
Training.py
import numpy
import tensorflow as tf
from tqdm import tqdm
import os
from pandas import np
from Data import trainDataSet, testDataSet
from MultiLayerModel import y, y_, x
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(logits=y + 1e-50, labels=y_))
-GradientDescentOptimizer is used to minimize loss
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
-Define accuracy
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
-Train
epochs = 50000
train_acc = numpy.zeros(epochs // 10)
test_acc = numpy.zeros(epochs // 10)
for i in tqdm(range(epochs), ascii=True):
if i % 10 == 0: # Record summary data, and the accuracy
- Check accuracy on train set
A = accuracy.eval(feed_dict={x: trainDataSet.drop(['font', 'fontVariant'], axis=1), y_: trainDataSet['font']})
train_acc[i // 10] = A
- And now the validation set
A = accuracy.eval(feed_dict={x: testDataSet.drop(['font', 'fontVariant'], axis=1), y_: testDataSet['font']})
test_acc[i // 10] = A
train_step.run(feed_dict={x: trainDataSet.drop(['font', 'fontVariant'], axis=1), y_: trainDataSet[['font']]})
Multilayermodel.py
import math
import tensorflow as tf
Create a Tensorflow session
session = tf.InteractiveSession()
These will be inputs for the model
Input pixels of images, flattened
400 = 20*20 which is the size
x = tf.placeholder("float", [None, 410])
Known labels
y_ = tf.placeholder("float", [None, 2])
Hidden layer 1 with 256 neurons
num_hidden1 = 256
Variables
W1 is for weights
b1 is for bias
W1 = tf.Variable(tf.truncated_normal([410, num_hidden1], stddev=1. / math.sqrt(410)))
b1 = tf.Variable(tf.constant(0.1, shape=[num_hidden1]))
Compute the activation function of the weighted sum -> produce 128 intermediate value
Nonlinear transform functions - activation function: sigmoid
h1 = tf.sigmoid(tf.matmul(x, W1) + b1)
Hidden Layer 2 with 64 neurons
num_hidden2 = 64
W2 = tf.Variable(tf.truncated_normal([num_hidden1, num_hidden2], stddev=2. / math.sqrt(num_hidden1)))
b2 = tf.Variable(tf.constant(0.2, shape=[num_hidden2]))
h2 = tf.sigmoid(tf.matmul(h1, W2) + b2)
Output Layer
Logistic regression again
W3 = tf.Variable(tf.truncated_normal([num_hidden2, 2], stddev=1. / math.sqrt(2)))
b3 = tf.Variable(tf.constant(0.1, shape=[2]))
Just initialize
session.run(tf.global_variables_initializer())
Define model
y = tf.nn.softmax(tf.matmul(h2, W3) + b3)
Thanks a lot for your work. Can this library simulate the interactions between multiple agents?
The documentation mentions we can use a diary_generator_builder.py to create our own diary generator, however such a file is not included.
Would it be possible for you to git push that file to the repo, please ๐?
Thank you so much
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.