Monday, 16 November 2020

Tensorflow and percolation pennies.

The following network was trained with available bank balance as input , and time spent at a cafe as output.
The bank balance x was normalised by dividing by 1000 so that the values fell between 0 and 1. Similarly, y the time spent at a location was divided by 1000.


The function y= mx + c = 0 was used to measure the gradient of the data.

REF: Algorithm for calculating mean squared error (MSE) from 

Pro Deep Learning with Tensorflow  by Santanu Pattanayak, page 144:


This model computes loss using MSE.
 
 The code from this program can be saved as filename.py

The network can be run from a terminal by typing:
python filename.py

Here is the code:
 
 
 import tensorflow as tf


# values of x = [0.14569, 0.17944, 0.15496, 0.07607, 0.01223, 0.00873, 0.26456, 0.19928, 0.01417, 0.00220, 0.16451, 0.09408, 0.23073, 0.13403, 0.11177, 0.29657, 0.21266, 0.11302, 0.29185, 0.24873, 0.15997, 0.09582, 0.30616, 0.11861, 0.18292, 0.12121, 0.08206]
# values of y = [0.381, 0.96, 0.385, 0.369, 0.3225, 0.28, 0.2776, 0.2641, 0.3415,0.6881, 0.4925, 0.5263, 0.2965, 0.8622, 0.4678, 0.3493, 0.3008, 0.2553, 0.178, 0.3826, 0.3378, 0.4217, 0.42, 0.4197, 0.3938, 0.5988, 0.5358]
x_train = [0.14569, 0.17944, 0.15496, 0.07607, 0.01223, 0.00873, 0.26456, 0.19928, 0.01417, 0.00220, 0.16451, 0.09408, 0.23073, 0.13403, 0.11177, 0.29657, 0.21266, 0.11302, 0.29185, 0.24873, 0.15997, 0.09582, 0.30616, 0.11861, 0.18292, 0.12121, 0.08206]
y_train = [0.381, 0.96, 0.385, 0.369, 0.3225, 0.28, 0.2776, 0.2641, 0.3415, 0.6881, 0.4925, 0.5263, 0.2965, 0.8622, 0.4678, 0.3493, 0.3008, 0.2553, 0.178,
0.3826, 0.3378, 0.4217, 0.42, 0.4197, 0.3938, 0.5988, 0.5358]


m = tf.Variable(0.)
c = tf.Variable(0.)

x = tf.placeholder(dtype = tf.float32)
y = tf.placeholder(dtype=tf.float32)



# using sigmoid function y = mx + c
model = tf.nn.sigmoid(tf.add(tf.multiply(x, m),c))

pred = tf.add(tf.multiply(x, m),c)
error = pred - y
loss = tf.reduce_mean(tf.square(error))

learn_rate = 0.005
num_epochs = 350

#using Gradient Descent with learning rate 0.005
train = tf.train.GradientDescentOptimizer(learn_rate).minimize(loss)
session = tf.Session()
init = tf.global_variables_initializer()

loss_trace = []


session.run(init)

#training model for 350 iterations
for epoch in range(num_epochs):
    session.run([train], {x:x_train, y:y_train})
#   lossval = session.run([loss], {x:x_train, y:y_train})
    loss_trace.append(session.run([loss], {x:x_train, y:y_train}))
    pred = tf.add(tf.multiply(x, m),c)
    error = pred - y
    error = session.run([error], {x:x_train, y:y_train})
    prediction = session.run([pred],{x:x_train, y:y_train})
    print('Iter: ', epoch, 'MSE in training: ', loss_trace[-1])
 
#final values of m and c
print('')
print('m =', session.run(m))
print('c =', session.run(c))
print('Final loss: ', loss_trace[-1])
print('Prediction :' , prediction)
print('Error: ', error)

import matplotlib.pyplot as plt
plt.xlabel('Number of epochs --------->')
plt.ylabel('Error (MSE) --------->')
plt.plot(loss_trace)
plt.show()
 
 
 
Here is the output:


(virtualenvironment.) david@debian:~/pythonvirenv$ python tftimeii.py
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:455: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:456: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:457: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-11-16 19:17:06.884453: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2020-11-16 19:17:06.884550: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2020-11-16 19:17:06.884579: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
Iter:  0 MSE in training:  [0.002089466]
Iter:  1 MSE in training:  [0.0020533486]
Iter:  2 MSE in training:  [0.0020179658]
Iter:  3 MSE in training:  [0.001983303]
Iter:  4 MSE in training:  [0.0019493455]
Iter:  5 MSE in training:  [0.0019160783]
Iter:  6 MSE in training:  [0.001883488]
Iter:  7 MSE in training:  [0.0018515604]
Iter:  8 MSE in training:  [0.0018202825]
Iter:  9 MSE in training:  [0.0017896408]
Iter:  10 MSE in training:  [0.0017596222]
.
.
.
.
Iter:  340 MSE in training:  [0.00031488354]
Iter:  341 MSE in training:  [0.0003148476]
Iter:  342 MSE in training:  [0.00031481232]
Iter:  343 MSE in training:  [0.00031477772]
Iter:  344 MSE in training:  [0.0003147438]
Iter:  345 MSE in training:  [0.0003147105]
Iter:  346 MSE in training:  [0.00031467783]
Iter:  347 MSE in training:  [0.0003146458]
Iter:  348 MSE in training:  [0.0003146143]
Iter:  349 MSE in training:  [0.00031458342]

m = 0.0048132725
c = 0.040683668
Final loss:  [0.00031458342]
Prediction : [array([0.04138491, 0.04154736, 0.04142953, 0.04104981, 0.04074254,
       0.04072569, 0.04195707, 0.04164286, 0.04075187, 0.04069426,
       0.0414755 , 0.0411365 , 0.04179423, 0.04132879, 0.04122165,
       0.04211114, 0.04170726, 0.04122766, 0.04208842, 0.04188087,
       0.04145365, 0.04114488, 0.0421573 , 0.04125457, 0.04156411,
       0.04126709, 0.04107865], dtype=float32)]
Error:  [array([ 0.00328491, -0.05445264,  0.00292953,  0.00414981,  0.00849254,
        0.01272569,  0.01419707,  0.01523286,  0.00660187, -0.02811574,
       -0.0077745 , -0.0114935 ,  0.01214423, -0.04489121, -0.00555835,
        0.00718114,  0.01162726,  0.01569767,  0.02428842,  0.00362087,
        0.00767365, -0.00102512,  0.0001573 , -0.00071543,  0.00218411,
       -0.01861291, -0.01250136], dtype=float32)]
(virtualenvironment.) david@debian:~/pythonvirenv$





Results
-------------

For y= m*x + c 
as we have a value for m and a value for c,  we can calculate the value of X when 0 = mx + c for the gradient at which the neural network starts to learn.
These are the steps:
y = m*x + c
0 = m*x + c
 
0 =  0.0048132725x + 0.040683668
-0.040683668 = 0.0048132725x
x =  -0.040683668 / 0.0048132725
x =  −8452.392421165


To scale up after normalising at the start we multiply by 1000.
 
The available bank balance at which a time spent at a location starts to change is
£ −8452.392421165
Conclusion
-------------------
The pattern that I infer from the results is that I am fixated in my time from 
a) In 1983 I received a sum of £8,700 received for a comminuted fracture of the left patella together with  severed anterior and posterior cruciate ligaments and a tendon.
 b) At the time of receiving this compensation I had a £700 pound overdraft from living expenses during my final year at Bristol university.
c) After receiving this compensation I bought a Honda CB400/4 F2 for £550
d) I earned two weekly salaries of £250 each  while dispatch riding.
e) After being knocked off of this motorbike I received another £1100 pounds in compensation.
f) I bough a replacement motorbike of a Honda CB750 F2 for £350.
g) I had a blow out of the front tyre, and later the gearbox needed a new layshaft and I also put new tyres on it.
h) When coming down from an LSD trip I allowed someone into talking me into swapping my bike for a 550cc motorbike that was not as tidy and later got arrested for drinking and driving.
i) I was later stabbed and unable to hold down a job for any great length of time due to Post-traumatic stress disorder (PTSD). 
j) My monetary situation has not changed since the balance of £8700. The deficit of £248 for that year was for beer, amphetamines, mushrooms, one line of cocaine, weed, cannabis, takeaways, petrol and a bottle of Smirnoff Blue Label vodka.

Friday, 14 August 2020

Tensorflow, antibiotics and MSE

The following network was trained with micrograms /ml of total antibiotic as input , and % success rate as output.
The antibiotic dose x was normalised by dividing by 1000 so that the values fell between 0 and 1. Similarly, y the success rate was divided by 100.


Figures for total dose and % success rate were obtained from table 2 from the web page

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5124968/

The link to table 2 is

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5124968/table/t2/?report=objectonly

Table 2 is contained in the chapter entitled Genetic algorithm with the deterministic model.
The function y= mx + c = 0 was used to measure the gradient of the data.

REF: Algorithm for calculating mean squared error (MSE) from 

Pro Deep Learning with Tensorflow  by Santanu Pattanayak, page 144:


This model computes loss using MSE.

A previous post uses cross entropy to calculate loss. The link is

http://pythonprediction.blogspot.com/2020/08/tensorflow-and-antibiotics.html


The code from this program can be saved as filename.py

The network can be run from a terminal by typing:
python3 filename.py

Here is the code:

import tensorflow as tf


# values of x = [0.118, 0.128, 0.122, 0.128, 0.141, 0.132, 0.143, 0.156]
# values of y = [0.912, 0.943, 0.923, 0.932, 0.944, 0.925, 0.940, 0.950]
x_train = [0.118, 0.128, 0.122, 0.128, 0.141, 0.132, 0.143, 0.156]
y_train = [0.912, 0.943, 0.923, 0.932, 0.944, 0.925, 0.940, 0.950]


m = tf.Variable(0.)
c = tf.Variable(0.)

x = tf.placeholder(dtype = tf.float32)
y = tf.placeholder(dtype=tf.float32)



# using sigmoid function y = mx + c
model = tf.nn.sigmoid(tf.add(tf.multiply(x, m),c))

pred = tf.add(tf.multiply(x, m),c)
error = pred - y
loss = tf.reduce_mean(tf.square(error))

learn_rate = 0.005
num_epochs = 350

#using Gradient Descent with learning rate 0.005
train = tf.train.GradientDescentOptimizer(learn_rate).minimize(loss)
session = tf.Session()
init = tf.global_variables_initializer()

loss_trace = []


session.run(init)

#training model for 350 iterations
for epoch in range(num_epochs):
    session.run([train], {x:x_train, y:y_train})
#   lossval = session.run([loss], {x:x_train, y:y_train})
    loss_trace.append(session.run([loss], {x:x_train, y:y_train}))
    pred = tf.add(tf.multiply(x, m),c)
    error = pred - y
    error = session.run([error], {x:x_train, y:y_train})
    prediction = session.run([pred],{x:x_train, y:y_train})
    print('Iter: ', epoch, 'MSE in training: ', loss_trace[-1])
 
#final values of m and c
print('')
print('m =', session.run(m))
print('c =', session.run(c))
print('Final loss: ', loss_trace[-1])
print('Prediction :' , prediction)
print('Error: ', error)

import matplotlib.pyplot as plt
plt.xlabel('Number of epochs --------->')
plt.ylabel('Error (MSE) --------->')
plt.plot(loss_trace)
plt.show()


Here is the output:


(virtualenvironment.) david@debian:~/pythonvirenv$ python3 antibioticmsev.py
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:455: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:456: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:457: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-08-14 18:47:47.336227: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2020-08-14 18:47:47.336326: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2020-08-14 18:47:47.336355: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
Iter:  0 MSE in training:  [0.85414684]
Iter:  1 MSE in training:  [0.8368502]
Iter:  2 MSE in training:  [0.819904]
Iter:  3 MSE in training:  [0.803301]
Iter:  4 MSE in training:  [0.7870342]
.
.
.
Iter:  347 MSE in training:  [0.0008233281]
Iter:  348 MSE in training:  [0.0008090532]
Iter:  349 MSE in training:  [0.00079507055]

m = 0.11940679
c = 0.89168817
Final loss:  [0.00079507055]
Prediction : [array([0.90577817, 0.9069722 , 0.9062558 , 0.9069722 , 0.9085245 ,
       0.90744984, 0.90876335, 0.91031563], dtype=float32)]
Error:  [array([-0.00622183, -0.03602779, -0.0167442 , -0.02502775, -0.03547549,
       -0.01755017, -0.03123665, -0.03968436], dtype=float32)]
(virtualenvironment.) david@debian:~/pythonvirenv$






Results
-------------

For y= m*x + c 
as we have a value for m and a value for c,  we can calculate the value of X when 0 = mx + c for the gradient at which the neural network starts to learn.
These are the steps:
y = m*x + c
0 = m*x + c
 
−0.89168817 =  0.11940679x
x = -0.89168817 / 0.11940679
x = -7.467650458



To scale up after normalising at the start we multiply by 1000
x = -7467 micrograms or -7.5 milligrams.
 

This is the dose at the gradient of the neural net starting to learn, therefore the therapeutic value of the antibiotic starts at the dose -7.5 milligrams /ml.

Conclusion
--------------------
The therapeutic starting value of the dose is negative which leads me to assume that the therapeutic value depends on the cumulative effect of antibiotics already in the environment or previous dosage.



Monday, 3 August 2020

Tensorflow and antibiotics

The following network was trained with micrograms /ml of total antibiotic as input , and % success rate as output.
The antibiotic dose x was normalised by dividing by 1000 so that the values fell between 0 and 1. Similarly, y the success rate was divided by 100.


Figures for total dose and % success rate were obtained from table 2 from the web page

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5124968/

The link to table 2 is

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5124968/table/t2/?report=objectonly

Table 2 is contained in the chapter entitled Genetic algorithm with the deterministic model.
The function y= mx + c = 0 was used to measure the gradient of the data.

Algorithm ref: Tensorflow for dummies by Mathew Scarpino, page 114:

This model computes loss with cross entropy.


The code from this program can be saved as filename.py

The network can be run from a terminal by typing:
python3 filename.py

Here is the code:


import tensorflow as tf
from math import log
from numpy import mean
# values of x = [0.118, 0.128, 0.122, 0.128, 0.141, 0.132, 0.143, 0.156]
# values of y = [0.912, 0.943, 0.923, 0.932, 0.944, 0.925, 0.940, 0.950]
x_train = [0.118, 0.128, 0.122, 0.128, 0.141, 0.132, 0.143, 0.156]
y_train = [0.912, 0.943, 0.923, 0.932, 0.944, 0.925, 0.940, 0.950]
m = tf.Variable(0.)
c = tf.Variable(0.)

x = tf.placeholder(dtype = tf.float32)
y = tf.placeholder(dtype=tf.float32)

# using sigmoid function y = mx + c
model = tf.nn.sigmoid(tf.add(tf.multiply(x, m),c))

loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(_sentinel = None, labels = y, logits = tf.nn.sigmoid(tf.add(tf.multiply(x, m),c)), name = None))


# calculate cross entropy
def cross_entropy(x_train, ytrain):
    return -sum([x_train[i]*log(y_train[i]) for i in range(len(x_train))])


results = list()
for i in range(len(x_train)):
    # create the distribution for each event {0, 1}
    expected = [1.0 - x_train[i], x_train[i]]
    predicted = [1.0 - y_train[i], y_train[i]]
    # calculate cross entropy for the two events
    ce = cross_entropy(expected, predicted)
    print('>[y=%.1f, yhat=%.1f] ce: %.3f nats' % (x_train[i], y_train[i], ce))
    results.append(ce)
 
# calculate the average cross entropy
mean_ce = mean(results)
print('Average Cross Entropy: %.3f nats' % mean_ce)


learn_rate = 0.005
num_epochs = 350

#using Gradient Descent with learning rate 0.005
train = tf.train.GradientDescentOptimizer(learn_rate).minimize(loss)
session = tf.Session()
init = tf.global_variables_initializer()


session.run(init)

#training model for 350 iterations
for epoch in range(num_epochs):
    session.run([train], {x:x_train, y:y_train})
    lossval = session.run([loss], {x:x_train, y:y_train})
                

#final values of m and c
print('')
print('m =', session.run(m))
print('c =', session.run(c))
print('Final loss: ', lossval)

Here is the output:


(virtualenvironment.) david@debian:~/pythonvirenv$ python3 sigmodelsigloss.py
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:455: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:456: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:457: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/david/pythonvirenv/virtualenvironment./lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
>[y=0.1, yhat=0.9] ce: 0.088 nats
>[y=0.1, yhat=0.9] ce: 0.088 nats
>[y=0.1, yhat=0.9] ce: 0.088 nats
>[y=0.1, yhat=0.9] ce: 0.088 nats
>[y=0.1, yhat=0.9] ce: 0.087 nats
>[y=0.1, yhat=0.9] ce: 0.088 nats
>[y=0.1, yhat=0.9] ce: 0.087 nats
>[y=0.2, yhat=0.9] ce: 0.087 nats
Average Cross Entropy: 0.088 nats
2020-08-06 22:15:04.888524: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2020-08-06 22:15:04.888610: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2020-08-06 22:15:04.888639: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

m = 0.017963253
c = 0.13417429
Final loss:  [0.49679244]
(virtualenvironment.) david@debian:~/pythonvirenv$



Results
-------------

For y= m*x + c 
as we have a value for m and a value for c,  we can calculate the value of X when 0 = mx + c for the gradient at which the neural network starts to learn.
These are the steps:
y = m*x + c
0 = m*x + c
0 = 0.017963253*x + 0.13417429
-0.13417429 =  0.017963253*x
x = -0.13417429 / 0.017963253


x = −−7.469375953




To scale up after normalising at the start we multiply by 1000
x = -7469 micrograms or -7.5 milligrams.
 

This is the dose at the gradient of the neural net starting to learn, therefore the therapeutic value of the antibiotic starts at the dose -7.5 milligrams /ml.

Conclusion
--------------------
The therapeutic starting value of the dose is negative which leads me to assume that the therapeutic value depends on the cumulative effect of antibiotics already in the environment or previous dosage.