Printing a generator returns "<generator object _as_iterable at 0x7f0476373e10>", need to print its values

MRAB python at mrabarnett.plus.com
Wed Nov 16 15:14:56 EST 2016


On 2016-11-16 20:01, vmahajan at centerpointmedia.com wrote:
> I am running Python2.7, wherein I am running the following price of code:
>
> y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True)
> print ('Predictions: {}'.format(str(y)))
>
> The output of the following is ""<generator object _as_iterable at 0x7f0476373e10>"
>
> However, the desired output must be in the format [1 0 0 1 1 0 0 1].
>
> Can someone help me print the output in this format
>
Pass the generator object to 'list':

y = list(m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True))
print('Predictions: {}'.format(y))




More information about the Python-list mailing list