Kernel: Python 3
Tensorflow 2 on CoCalc
This shows some examples from the migration guide.
To get TF2 in Cocalc:
Select "New Project..." → "Advanced ..." → "Custom Software" → scroll down to "Tensorflow 2"
Hint: This project also support code formatting!
In [1]:
'2.0.0-rc0'
In [2]:
In [3]:
tf.Tensor(
[[1. 0.]
[1. 0.]], shape=(2, 2), dtype=float32)
In [0]:
In [0]:
Estimator: Linear Model
Shamelessly copied from https://www.tensorflow.org/alpha/tutorials/estimators/linear
In [4]:
In [5]:
In [6]:
Loading data reqires that your project has access to the internet
In [7]:
In [8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fef64044a20>
In [9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fef5cb3aba8>
In [10]:
In [11]:
In [12]:
Some feature keys: ['sex', 'age', 'n_siblings_spouses', 'parch', 'fare', 'class', 'deck', 'embark_town', 'alone']
A batch of class: [b'Third' b'First' b'Third' b'Third' b'Second' b'First' b'Third' b'First'
b'Third' b'First']
A batch of Labels: [0 0 0 0 0 1 0 1 0 0]
In [13]:
array([[47.],
[40.],
[28.],
[28.],
[18.],
[60.],
[24.],
[35.],
[22.],
[61.]], dtype=float32)
In [14]:
WARNING: Logging before flag parsing goes to stderr.
W0706 10:01:13.695795 140667409536832 deprecation.py:323] From /srv/conda/envs/notebook/lib/python3.6/site-packages/tensorflow/python/feature_column/feature_column_v2.py:2655: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
W0706 10:01:13.700002 140667409536832 deprecation.py:323] From /srv/conda/envs/notebook/lib/python3.6/site-packages/tensorflow/python/feature_column/feature_column_v2.py:4215: IndicatorColumn._variable_shape (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
W0706 10:01:13.700935 140667409536832 deprecation.py:323] From /srv/conda/envs/notebook/lib/python3.6/site-packages/tensorflow/python/feature_column/feature_column_v2.py:4270: VocabularyListCategoricalColumn._num_buckets (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
array([[1., 0.],
[1., 0.],
[1., 0.],
[0., 1.],
[1., 0.],
[0., 1.],
[1., 0.],
[0., 1.],
[1., 0.],
[1., 0.]], dtype=float32)
In [15]:
{'accuracy': 0.75757575, 'accuracy_baseline': 0.625, 'auc': 0.83039486, 'auc_precision_recall': 0.77159166, 'average_loss': 0.50849754, 'label/mean': 0.375, 'loss': 0.49981472, 'precision': 0.72727275, 'prediction/mean': 0.28824264, 'recall': 0.56565654, 'global_step': 200}
In [16]:
In [17]:
{'accuracy': 0.7613636, 'accuracy_baseline': 0.625, 'auc': 0.84762776, 'auc_precision_recall': 0.79725146, 'average_loss': 0.4671647, 'label/mean': 0.375, 'loss': 0.45873976, 'precision': 0.6956522, 'prediction/mean': 0.39844975, 'recall': 0.64646465, 'global_step': 200}
In [18]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fef5c5bd0f0>
In [19]:
(0, 1.05)
In [0]:
In [0]: