Python Troubleshooting Q&A
1. Pyfolio - AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime'
-
# remove your installed pyfolio library
pip uninstall pyfolio
# Install it again from its github repo
pip install git+https://github.com/quantopian/pyfolio
2. For using git, add git path to the PATH on Windows
-
Find Git executable file (git.exe) is located
in C:\Program Files\Git\bin
or C:\Program Files\Git\cmd
or C:\Users\XXX\AppData\Local\GitHubDesktop\app-3.0.6\resources\app\git\cmd
or other directories
The directory that is found must be added to the PATH environment variable and the version of Git needs to be confirmed as follows.
C:\Users\shlee>git --version
git version 2.35.4.windows.1
3. TabError: inconsistent use of tabs and spaces in indentation
- This problem occurs when we mix tabs and spaces in the same code block. To solve the error, remove the spacing and only use tabs or spaces, but don't mix the two in the same code block.
4. Multiple prints in Jupyter notebook
# InteractiveShell.ast_node_interactivity
# : 'all' | 'last' | 'last_expr' | 'none'
# (default : 'last_expr')
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
5. ValueError: Please initialize `Bidirectional` layer with a `tf.keras.layers.Layer` instance.
Just delete tensorflow.#from tensorflow.keras.layers import Bidirectional, Dropout, Activation, Dense, LSTM
#from tensorflow.python.keras.layers import CuDNNLSTM
#from tensorflow.keras.models import Sequential
from keras.layers import Bidirectional, Dropout, Activation, Dense, LSTM
from keras.layers import CuDNNLSTM
from keras.models import Sequential
6. Current directory of the running file
os.path.abspath('')7. set_random_seed() error
Q : ImportError: cannot import name 'set_random_seed' from 'tensorflow' (C:\Users\shlee\anaconda3\lib\site-packages\tensorflow\__init__.py)A: TensorFlow API has been updated from set_random_seed() to set_seed()
to be added....
#from tensorflow import set_random_seed
#set_random_seed(2)
from tensorflow.random import set_seed
set_seed(2)
to be added....
No comments:
Post a Comment