working with Keras on a Jupyter lab using Tensorflow - keras

I'm trying to use keras on a jupyter lab using tensorflow (python 3.6) through miniconda.
Jupyter lab keeps give me a restarting error(Kernel Restarting The kernel for Desktop/Transfer/Untitled.ipynb appears to have died. It will restart automatically.)
Because the kernel restarting error is evident whenever I try to import keras. The code I used is (from keras.preprocessing.image import ImageDataGenerator, load_img, img_to_array, array_to_img).
Code
Therefore, I assume that there is a problem between keras and kernel even though I already installed ipykernel in my tensorflow directory ((tensorflow) C:\Users\user).
Pip_list
Still couldn't figure out this kernel and keras problem :(.

Related

When downloading MNIST, I can't get the "processed" folder

I am following a tutorial in here https://www.youtube.com/watch?v=IQpP_cH8rrA
I followed all the initial steps (except I am in VS not in Colab) but I stop pretty soon because when running:
torchvision.datasets.MNIST('./', download=True)
I get only the raw folder, not the processed one (which should contain training.pt and test.pt).
Can anybody help?
I am running on python 3.8.10, torch version 1.10.1, torchvision 0.11.2
PS: I found the same issue here https://github.com/pytorch/vision/issues/4685
should I really downgrade torchvision to 0.9.1 to have both folders?
if yes, how can I just downgrade torchvision from cmd, without uninstall torch and install everything back?
I found this work around, downloading the data from tensorflow and then just switching the data types so you can follow along the tutorial again. hope this helps
import tensorflow as tf
import torch
import numpy as np
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
print(x_train.shape)
images = torch.from_numpy(x_train)
ground_truth = torch.from_numpy(y_train)
print(images.shape)
print(ground_truth.shape)
`
This works in my notebook, hopefully it does for you too
I am not sure if this answer will help anyone but this was my solution to it (after lots of trying and searching in the internet, I am not too experienced):
(I used anaconda prompt)
I created a virtual environment called "test" for python 3.6:
conda create -n test python=3.6
activate test
I installed the recommended torchvision version on it:
pip install torchvision==0.9.1
I ran my program in the virtual environment:
python yourprogram.py
I am sure this is not the best solution to exist but it worked for me and was very easy as it is just a few lines in anaconda prompt.

import of keras and tensorflow seems to break pycharm

I'm facing a weird issue.
I'm working in Pycharm IDE and I want to use keras with tensorflow backend.
When I try to import keras or tensorflow pycharm process finished with exit code -1073741819 (0xC0000005).
For example
import tensorflow as tf
n_input = 2
print (n_input)
returns message described above without printing anything.
If i comment the tf import it works.
Keras and tensorflow are correctly installed under the python interpreter of my choice.
I'm on windows machine, Python 3.6.8
Thanks

Conflict between tensorflow/PIL/pillow and scikit-image?

I am tying to rebuild my computer to run Spyder in a tensorflow environment for some image processing. In the past this worked and I had scikit-image working fully in that environment, and accessible from Spyder. Something has changed. I have:
1) re-installed Anaconda
2) re-installed tensorflow in a conda environment
3) installed libraries as needed, including Spyder.
Then I start Spyder from the Conda navigator, in the tensorflow environment. This seems to work, I can import tensorflow, keras, pandas, sklearn, etc. But skimage only works partially. for example:
import skimage
works fine. But,
import skimage.io as io
does not. The error comes out as 'from PIL import Image' Is this something about PIL/pillow not co-existing in the same environment? Can this be fixed easily or should I just use opencv for image io? I have tried other modules in skimage and they all import. So using another package to open an image would not be the end of the world, but it would be nice to get the entirety of skimage working.
Thanks

Raspberry PI import tensorflow Segmentation fault

I have installed tensorflow on a Raspberry PI 3 and it worked correctly (following these instructions). After installing a number of libraries that I needed for loading a Keras model trained on my PC (numpy, scipy etc) I have observed the following error while importing tensorflow:
Runtime Error: module compiled against API version 0xc but this version of numpy is 0xa
Segmentation fault
I have updated all the necessary libraries, and importing any of them doesn't result in an error in a Python 3 script. Also the error is not keras related, because the statement import tensorflow raises an error no matter what follows after it. Should I uninstall tensorflow and start all over again?

ImportError: No module named theano.sandbox using Jupyter notebook

I am trying to work with Keras on some small datasets locally, using my cpu.
I started a jupyter notebook, and selected what I think might be the right kernel, which would be the conda env:tensorflow:
So I try to import from the sandbox:
from theano.sandbox import cuda .
and I get
ImportError: No module named theano.sandbox
I don't get it. Theano is installed. Tensorflow is installed. Anaconda is installed. How can I figure out what is going on?

Resources